本文整理汇总了Java中net.minecraftforge.items.wrapper.InvWrapper类的典型用法代码示例。如果您正苦于以下问题:Java InvWrapper类的具体用法?Java InvWrapper怎么用?Java InvWrapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InvWrapper类属于net.minecraftforge.items.wrapper包,在下文中一共展示了InvWrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getItemHandler
import net.minecraftforge.items.wrapper.InvWrapper; //导入依赖的package包/类
public static IItemHandler getItemHandler(World world, BlockPos pos, EnumFacing side, boolean includeEntities) {
TileEntity te = world.getTileEntity(pos);
if (te instanceof IDrawer) {
return new DrawerWrapper((IDrawer) te);
} else if (te instanceof IDrawerGroup) {
return new DrawerGroupWrapper((IDrawerGroup) te);
} else if (te == null || !te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) {
IInventory inv = includeEntities ? TileEntityHopper.getInventoryAtPosition(world, pos.getX(), pos.getY(), pos.getZ()) : (te instanceof IInventory ? (IInventory) te : null);
if (inv != null) {
if (inv instanceof ISidedInventory) {
return new SidedInvWrapper((ISidedInventory) inv, side);
} else {
return new InvWrapper(inv);
}
} else
return null;
} else {
return te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
}
}
示例2: interactWithFluidHandler
import net.minecraftforge.items.wrapper.InvWrapper; //导入依赖的package包/类
/**
* Used to handle the common case of a fluid item right-clicking on a fluid handler.
* First it tries to fill the container item from the fluid handler,
* if that action fails then it tries to drain the container item into the fluid handler.
*
* Returns true if interaction was successful.
* Returns false if interaction failed.
*/
public static boolean interactWithFluidHandler(ItemStack stack, IFluidHandler fluidHandler, EntityPlayer player)
{
if (stack == null || fluidHandler == null || player == null)
{
return false;
}
IItemHandler playerInventory = new InvWrapper(player.inventory);
return tryFillContainerAndStow(stack, fluidHandler, playerInventory, Integer.MAX_VALUE, player) ||
tryEmptyContainerAndStow(stack, fluidHandler, playerInventory, Integer.MAX_VALUE, player);
}
示例3: getCapability
import net.minecraftforge.items.wrapper.InvWrapper; //导入依赖的package包/类
@SuppressWarnings ("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
return (T) new InvWrapper(getStorage());
}
return super.getCapability(capability, facing);
}
示例4: getCapability
import net.minecraftforge.items.wrapper.InvWrapper; //导入依赖的package包/类
@SuppressWarnings ("unchecked")
@Override
public <T> T getCapability(@Nonnull Capability<T> capability, EnumFacing facing) {
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
return (T) new InvWrapper(this);
}
return null;
}
示例5: getItemHandlerCap
import net.minecraftforge.items.wrapper.InvWrapper; //导入依赖的package包/类
@Deprecated
public static IItemHandler getItemHandlerCap(TileEntity tileEntity, EnumFacing face) {
if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, face)) {
return tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, face);
} else if (tileEntity instanceof ISidedInventory && face != null) {
return new SidedInvWrapper(((ISidedInventory) tileEntity), face);
} else if (tileEntity instanceof IInventory) {
return new InvWrapper(((IInventory) tileEntity));
}
return new EmptyHandler();
}
示例6: getItemHandler_Raw
import net.minecraftforge.items.wrapper.InvWrapper; //导入依赖的package包/类
/**
* Grabs the IItemHandler capability for the tile,
* Will wrap if the cap doesnt exist, If you care about only interacting with the cap,
* Then use {@link #hasItemHandler_Raw} to check if the tile only has the cap before calling.
*
* @param tile The tile.
* @param face The face.
* @return The handler, wrapped if the tile uses legacy interfaces and no cap.
*/
public static IItemHandler getItemHandler_Raw(TileEntity tile, EnumFacing face) {
if (hasItemHandler(tile, face)) {
if (hasItemHandler_Raw(tile, face)) {
return tile.getCapability(ITEM_HANDLER, face);
} else {
if (tile instanceof ISidedInventory && face != null) {
return new SidedInvWrapper((ISidedInventory) tile, face);
} else {
return new InvWrapper((IInventory) tile);
}
}
}
return null;
}
示例7: onBlockActivated
import net.minecraftforge.items.wrapper.InvWrapper; //导入依赖的package包/类
@Override
public boolean onBlockActivated(World w, BlockPos pos, IBlockState state, EntityPlayer p, EnumHand h, EnumFacing f, float x, float y, float z) {
ItemStack is = p.getHeldItem(h);
if (!w.isRemote) {
TileEntity te = w.getTileEntity(pos);
if (te instanceof TileEntityFluxGen) {
FluidActionResult far = FluidUtil.tryEmptyContainerAndStow(is, (TileEntityFluxGen) te, new InvWrapper(p.inventory), TileEntityFluxGen.fluidCap, p);
if (far.success)
p.setHeldItem(h, far.result);
else
p.openGui(MCFlux.MF, R.MF_GUI_FLUXGEN, w, pos.getX(), pos.getY(), pos.getZ());
}
}
return true;
}
示例8: ContainerHandyBag
import net.minecraftforge.items.wrapper.InvWrapper; //导入依赖的package包/类
public ContainerHandyBag(EntityPlayer player, ItemStack containerStack)
{
super(player, new InventoryItemModular(containerStack, player, true, ModuleType.TYPE_MEMORY_CARD_ITEMS));
this.inventoryItemModular = (InventoryItemModular) this.inventory;
this.inventoryItemModular.setHostInventory(this.playerInv);
this.craftMatrix = new InventoryCraftingEnderUtilities(2, 2, new ItemStackHandlerBasic(4), this.craftResult, player);
this.craftMatrixWrapper = new InvWrapper(this.craftMatrix);
this.inventoryNonWrapped = (InventoryItemModular) this.inventory;
this.addCustomInventorySlots();
this.addPlayerInventorySlots(8, 174);
}
示例9: getWrappedCraftingInventoryFromContainer
import net.minecraftforge.items.wrapper.InvWrapper; //导入依赖的package包/类
/**
* Gets a wrapped **InventoryCraftingPermissions** instance.
* This must be used by anything that wants to modify the crafting grid contents,
* so that the recipe and output slot will get updated properly!
* @param gridId
* @param player
* @return
*/
@Nullable
private IItemHandler getWrappedCraftingInventoryFromContainer(int gridId, EntityPlayer player)
{
if (player.openContainer instanceof ContainerCreationStation)
{
return new InvWrapper(((ContainerCreationStation) player.openContainer).getCraftingInventory(gridId));
}
return null;
}
示例10: moveItemsToEnderChest
import net.minecraftforge.items.wrapper.InvWrapper; //导入依赖的package包/类
/**
* Moves as many items from the output slot to the owner's vanilla Ender Chest as possible.
* Tries to first fill matching stacks to their max, then puts items into the first empty slot.
* @return true if some items were moved
*/
private boolean moveItemsToEnderChest()
{
if (this.getBaseItemHandler().getStackInSlot(SLOT_OUTPUT).isEmpty() ||
this.ownerData == null || this.ownerData.getOwnerUUID() == null)
{
return false;
}
EntityPlayer player = this.getWorld().getPlayerEntityByUUID(this.ownerData.getOwnerUUID());
if (player == null)
{
return false;
}
// Player is online
ItemStack stack = this.getBaseItemHandler().extractItem(SLOT_OUTPUT, 64, false);
if (stack.isEmpty())
{
return false;
}
int origSize = stack.getCount();
IItemHandler inv = new InvWrapper(player.getInventoryEnderChest());
stack = InventoryUtils.tryInsertItemStackToInventory(inv, stack);
if (stack.isEmpty())
{
return true;
}
boolean movedItems = origSize != stack.getCount();
this.getBaseItemHandler().insertItem(SLOT_OUTPUT, stack, false);
return movedItems;
}
示例11: tryGetHandler
import net.minecraftforge.items.wrapper.InvWrapper; //导入依赖的package包/类
public static IItemHandler tryGetHandler(TileEntity te, EnumFacing side) {
if (te == null) return null;
if (te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side))
return te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
if (te instanceof ISidedInventory)
return new SidedInvWrapper((ISidedInventory)te, side);
if (te instanceof IInventory)
return new InvWrapper((IInventory)te);
return null;
}
示例12: getCapability
import net.minecraftforge.items.wrapper.InvWrapper; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ? (T) new InvWrapper(inv) : null;
}
示例13: TileEntityItemHandler
import net.minecraftforge.items.wrapper.InvWrapper; //导入依赖的package包/类
public TileEntityItemHandler() {
itemCapability = new InvWrapper(this);
}
示例14: createUnSidedHandler
import net.minecraftforge.items.wrapper.InvWrapper; //导入依赖的package包/类
private IItemHandler createUnSidedHandler() {
return new InvWrapper(this);
}
示例15: PlayerMainInvWrapperNoSync
import net.minecraftforge.items.wrapper.InvWrapper; //导入依赖的package包/类
public PlayerMainInvWrapperNoSync(InventoryPlayer inv)
{
super(new InvWrapper(inv), 0, inv.mainInventory.size());
this.inventoryPlayer = inv;
}