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


Java IItemHandlerModifiable类代码示例

本文整理汇总了Java中net.minecraftforge.items.IItemHandlerModifiable的典型用法代码示例。如果您正苦于以下问题:Java IItemHandlerModifiable类的具体用法?Java IItemHandlerModifiable怎么用?Java IItemHandlerModifiable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IItemHandlerModifiable类属于net.minecraftforge.items包,在下文中一共展示了IItemHandlerModifiable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readCapabilities

import net.minecraftforge.items.IItemHandlerModifiable; //导入依赖的package包/类
protected void readCapabilities(NBTTagCompound nbt, @Nullable EnumFacing side){
    IItemHandler inventory = this.getInventory(side);
    if(inventory != null && inventory instanceof IItemHandlerModifiable && nbt.hasKey("Inventory")){
        for(int i = 0; i < inventory.getSlots(); i++){ // clear the inventory, otherwise empty stacks doesn't get overriden while syncing. Forge Bug?
            ((IItemHandlerModifiable) inventory).setStackInSlot(i, ItemStack.EMPTY);
        }
        CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.readNBT(inventory, side, nbt.getTag("Inventory"));
    }
    IFluidHandler tank = getTank(side);
    if(tank != null && tank instanceof IFluidTank && nbt.hasKey("FluidTank")){
        CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.readNBT(tank, side, nbt.getCompoundTag("FluidTank"));
    }
    IEnergyStorage energy = getEnergy(side);
    if(energy != null && energy instanceof EnergyStorage && nbt.hasKey("Energy")){
        CapabilityEnergy.ENERGY.readNBT(energy, side, nbt.getTag("Energy"));
    }
}
 
开发者ID:canitzp,项目名称:Metalworks,代码行数:18,代码来源:TileBase.java

示例2: removeInputsFromInventory

import net.minecraftforge.items.IItemHandlerModifiable; //导入依赖的package包/类
public static void removeInputsFromInventory(List<RecipeInput> inputs, IItemHandlerModifiable inv, int start, int numSlots)
{
    List<RecipeInput> remaining = Lists.newLinkedList(inputs);

    for (int i = start; i < start + numSlots; i++)
    {
        ItemStack stack = inv.getStackInSlot(i);
        for (Iterator<RecipeInput> iterator = remaining.iterator(); iterator.hasNext(); )
        {
            RecipeInput input = iterator.next();
            if (stackMatchesRecipeInput(stack, input, true))
            {
                extractInput(input, inv, i);

                iterator.remove();
                break;
            }
        }
    }
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:21,代码来源:ItemHelper.java

示例3: getItemHandlerCapability

import net.minecraftforge.items.IItemHandlerModifiable; //导入依赖的package包/类
@Nullable
private IItemHandlerModifiable getItemHandlerCapability(@Nullable EnumFacing facing)
{
    Capability<IItemHandler> capability = CapabilityItemHandler.ITEM_HANDLER_CAPABILITY;

    List<IItemHandlerModifiable> handlers = Lists.newLinkedList();

    for (TileEntityModule module : modules.values())
    {
        if (module.hasCapability(capability, facing))
            handlers.add((IItemHandlerModifiable) module.getCapability(capability, facing));
    }

    if (handlers.size() == 1)
        return handlers.get(0);
    else if (handlers.size() > 1)
        return new CombinedInvWrapper(handlers.toArray(new IItemHandlerModifiable[handlers.size()]));
    else
        return null;
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:21,代码来源:TileEntitySimple.java

示例4: extract

import net.minecraftforge.items.IItemHandlerModifiable; //导入依赖的package包/类
public static ItemStack extract(TileEntity tile, EnumFacing from, boolean fullStack) {

		if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, from)) {
			IItemHandlerModifiable handler = (IItemHandlerModifiable) tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, from);
			if (handler != null) {
				int invSize = handler.getSlots();

				for (int i = 0; i < invSize; i++) {
					ItemStack current = handler.getStackInSlot(i);

					if (current != null && !current.isEmpty() && current.getItem() != Items.AIR) {
						ItemStack stack = handler.extractItem(i, !fullStack ? 1 : current.getCount(), false);
						return stack;
					}
				}
			}
		} // TODO: TileEntities that don't have capabilities - needs testing

		return null;
	}
 
开发者ID:oMilkyy,项目名称:SimpleTubes,代码行数:21,代码来源:TubeUtil.java

示例5: copyInventory

import net.minecraftforge.items.IItemHandlerModifiable; //导入依赖的package包/类
private void copyInventory(IItemHandlerModifiable from, int[][] fromSlotIds, IItemHandlerModifiable to, int[][] toSlotIds)
{
    for (int i = 0; i < fromSlotIds.length; i++)
    {
        int[] slotIds = fromSlotIds[i];

        for (int j = 0; j < slotIds.length; j++)
        {
            int fromSlot = slotIds[j];
            if (j < toSlotIds[i].length)
            {
                int toSlot = toSlotIds[i][j];

                to.setStackInSlot(toSlot, from.getStackInSlot(fromSlot));
                from.setStackInSlot(fromSlot, ItemStack.EMPTY);
            }
        }
    }
}
 
开发者ID:cubex2,项目名称:morefurnaces,代码行数:20,代码来源:ItemUpgrade.java

示例6: putStack

import net.minecraftforge.items.IItemHandlerModifiable; //导入依赖的package包/类
@Override
public void putStack(ItemStack stack)
{
    if (this.getItemHandler() instanceof IItemHandlerModifiable)
    {
        //System.out.printf("SlotItemHandlerGeneric#putStack() - setStackInSlot() - slot: %3d stack: %s\n", this.getSlotIndex(), stack);
        ((IItemHandlerModifiable) this.getItemHandler()).setStackInSlot(this.getSlotIndex(), stack);
    }
    else
    {
        EnderUtilities.logger.warn("SlotItemHandlerGeneric#putStack() by insertItem() - things will not work well!");
        this.getItemHandler().insertItem(this.getSlotIndex(), stack, false);
    }

    this.onSlotChanged();
}
 
开发者ID:maruohon,项目名称:enderutilities,代码行数:17,代码来源:SlotItemHandlerGeneric.java

示例7: setDead

import net.minecraftforge.items.IItemHandlerModifiable; //导入依赖的package包/类
@Override
public void setDead() {
	//System.out.println("death and drop");
	if (!this.getEntityWorld().isRemote) {
		Block.spawnAsEntity(this.getEntityWorld(), this.getPosition(), new ItemStack(ItemLoader.itemTripod, 1));
		// last slot useless,so= -2 !=-1
		for (int i = Inventory.getSlots() - 2; i >= 0; --i) {
			if (Inventory.getStackInSlot(i) != null) {
				Block.spawnAsEntity(this.getEntityWorld(), this.getPosition(), Inventory.getStackInSlot(i));
				((IItemHandlerModifiable) Inventory).setStackInSlot(i, null);
			}
		}
	}
	super.setDead();
}
 
开发者ID:PorPit,项目名称:MineCamera,代码行数:16,代码来源:EntityTripod.java

示例8: breakBlock

import net.minecraftforge.items.IItemHandlerModifiable; //导入依赖的package包/类
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
	TileEntityPhotoProcessor te = (TileEntityPhotoProcessor) worldIn.getTileEntity(pos);

	IItemHandler inv = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP);

	for (int i = inv.getSlots() - 1; i >= 0; --i) {
		if (inv.getStackInSlot(i) != null) {
			Block.spawnAsEntity(worldIn, pos, inv.getStackInSlot(i));
			((IItemHandlerModifiable) inv).setStackInSlot(i, null);
		}
	}

	super.breakBlock(worldIn, pos, state);
}
 
开发者ID:PorPit,项目名称:MineCamera,代码行数:16,代码来源:BlockPhotoProcessor.java

示例9: writeCapabilities

import net.minecraftforge.items.IItemHandlerModifiable; //导入依赖的package包/类
protected void writeCapabilities(NBTTagCompound nbt, @Nullable EnumFacing side){
    IItemHandler inventory = this.getInventory(side);
    if(inventory != null && inventory instanceof IItemHandlerModifiable){
        nbt.setTag("Inventory", CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.writeNBT(inventory, side));
    }
    IFluidHandler tank = getTank(side);
    if(tank != null && tank instanceof IFluidTank){
        nbt.setTag("FluidTank", CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.writeNBT(tank, side));
    }
    IEnergyStorage energy = getEnergy(side);
    if(energy != null && energy instanceof EnergyStorage){
        nbt.setTag("Energy", CapabilityEnergy.ENERGY.writeNBT(energy, side));
    }
}
 
开发者ID:canitzp,项目名称:Metalworks,代码行数:15,代码来源:TileBase.java

示例10: extractInput

import net.minecraftforge.items.IItemHandlerModifiable; //导入依赖的package包/类
static void extractInput(RecipeInput input, IItemHandlerModifiable from, int slot)
{
    if (input.isOreClass())
    {
        from.extractItem(slot, input.getOreClass().getAmount(), false);
    } else
    {
        ItemStack toExtract = input.getStack().getItemStack();
        from.extractItem(slot, toExtract.getCount(), false);
    }
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:12,代码来源:ItemHelper.java

示例11: ItemHandlerMachine

import net.minecraftforge.items.IItemHandlerModifiable; //导入依赖的package包/类
public ItemHandlerMachine(int inputSlots, int outputSlots, int fuelSlots, TileEntity tile)
{
    super(inputSlots + outputSlots + fuelSlots, tile);
    this.inputSlots = inputSlots;
    this.outputSlots = outputSlots;
    this.fuelSlots = fuelSlots;

    inputHandler = inputSlots > 0 ? new RangedWrapper(this, 0, inputSlots)
                                  : (IItemHandlerModifiable) EmptyHandler.INSTANCE;
    outputHandler = outputSlots > 0 ? new RangedWrapper(this, inputSlots, inputSlots + outputSlots)
                                    : (IItemHandlerModifiable) EmptyHandler.INSTANCE;
    fuelHandler = fuelSlots > 0 ? new RangedWrapper(this, inputSlots + outputSlots, inputSlots + outputSlots + fuelSlots)
                                : (IItemHandlerModifiable) EmptyHandler.INSTANCE;
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:15,代码来源:ItemHandlerMachine.java

示例12: handlerForSide

import net.minecraftforge.items.IItemHandlerModifiable; //导入依赖的package包/类
private Optional<IItemHandler> handlerForSide(EnumFacing facing)
{
    List<IItemHandlerModifiable> handlers = Lists.newArrayList();
    if (ArrayUtils.contains(supplier.sidesInput, facing))
        handlers.add(invHandler.getInputHandler());
    if (ArrayUtils.contains(supplier.sidesOutput, facing))
        handlers.add(invHandler.getOutputHandler());
    if (ArrayUtils.contains(supplier.sidesFuel, facing))
        handlers.add(invHandler.getFuelHandler());

    return Optional.ofNullable(handlers.isEmpty() ? null : new CombinedInvWrapper(handlers.toArray(new IItemHandlerModifiable[handlers.size()])));
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:13,代码来源:TileEntityModuleMachine.java

示例13: insert

import net.minecraftforge.items.IItemHandlerModifiable; //导入依赖的package包/类
public static boolean insert(ItemStack stack, TileEntity tile, EnumFacing from) {
	if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, from)) {
		IItemHandlerModifiable handler = (IItemHandlerModifiable) tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, from);
		if (handler != null) {
			if (ItemHandlerHelper.insertItemStacked(handler, stack, false).isEmpty()) {
				return true;
			} else {
				return false;
			}
		}
	} // TODO: TileEntities that don't have capabilities - needs testing
	return false;
}
 
开发者ID:oMilkyy,项目名称:SimpleTubes,代码行数:14,代码来源:TubeUtil.java

示例14: createBottomSideHandler

import net.minecraftforge.items.IItemHandlerModifiable; //导入依赖的package包/类
private CombinedInvWrapper createBottomSideHandler()
{
    IItemHandlerModifiable[] handlers = new IItemHandlerModifiable[outputHandlers.length + 1];
    System.arraycopy(outputHandlers, 0, handlers, 0, outputHandlers.length);
    handlers[handlers.length - 1] = fuelHandler;

    return new CombinedInvWrapper(handlers);
}
 
开发者ID:cubex2,项目名称:morefurnaces,代码行数:9,代码来源:ItemHandlerFurnace.java

示例15: getHandlerForSide

import net.minecraftforge.items.IItemHandlerModifiable; //导入依赖的package包/类
public IItemHandlerModifiable getHandlerForSide(@Nonnull EnumFacing facing)
{
    if (facing == EnumFacing.DOWN)
        return bottomSideHandler;
    if (facing == EnumFacing.UP)
        return topSideHandler;
    return sidesSideHandler;
}
 
开发者ID:cubex2,项目名称:morefurnaces,代码行数:9,代码来源:ItemHandlerFurnace.java


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