当前位置: 首页>>代码示例>>Java>>正文


Java InvWrapper类代码示例

本文整理汇总了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);
	}
}
 
开发者ID:tom5454,项目名称:Toms-Mod,代码行数:21,代码来源:TomsModUtils.java

示例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);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:20,代码来源:FluidUtil.java

示例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);
}
 
开发者ID:TheCBProject,项目名称:EnderStorage,代码行数:9,代码来源:TileEnderChest.java

示例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;
}
 
开发者ID:TheCBProject,项目名称:CodeChickenLib,代码行数:9,代码来源:InventorySimple.java

示例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();
}
 
开发者ID:TheCBProject,项目名称:CodeChickenLib,代码行数:12,代码来源:InventoryUtils.java

示例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;
}
 
开发者ID:TheCBProject,项目名称:CodeChickenLib,代码行数:24,代码来源:InventoryUtils.java

示例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;
}
 
开发者ID:Szewek,项目名称:Minecraft-Flux,代码行数:16,代码来源:BlockFluxGen.java

示例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);
}
 
开发者ID:maruohon,项目名称:enderutilities,代码行数:13,代码来源:ContainerHandyBag.java

示例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;
}
 
开发者ID:maruohon,项目名称:enderutilities,代码行数:19,代码来源:TileEntityCreationStation.java

示例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;
}
 
开发者ID:maruohon,项目名称:enderutilities,代码行数:43,代码来源:TileEntityEnderFurnace.java

示例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;
}
 
开发者ID:OpenMods,项目名称:OpenModsLib,代码行数:15,代码来源:InventoryUtils.java

示例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;
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:6,代码来源:BackpackInventoryHandler.java

示例13: TileEntityItemHandler

import net.minecraftforge.items.wrapper.InvWrapper; //导入依赖的package包/类
public TileEntityItemHandler() {
	itemCapability = new InvWrapper(this);
}
 
开发者ID:zerofall,项目名称:EZStorage2,代码行数:4,代码来源:TileEntityItemHandler.java

示例14: createUnSidedHandler

import net.minecraftforge.items.wrapper.InvWrapper; //导入依赖的package包/类
private IItemHandler createUnSidedHandler() {
    return new InvWrapper(this);
}
 
开发者ID:GirafiStudios,项目名称:Culinary-Cultivation,代码行数:4,代码来源:TileEntityInventory.java

示例15: PlayerMainInvWrapperNoSync

import net.minecraftforge.items.wrapper.InvWrapper; //导入依赖的package包/类
public PlayerMainInvWrapperNoSync(InventoryPlayer inv)
{
    super(new InvWrapper(inv), 0, inv.mainInventory.size());

    this.inventoryPlayer = inv;
}
 
开发者ID:maruohon,项目名称:enderutilities,代码行数:7,代码来源:PlayerMainInvWrapperNoSync.java


注:本文中的net.minecraftforge.items.wrapper.InvWrapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。