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


Java CombinedInvWrapper类代码示例

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


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

示例1: onContentsChanged

import net.minecraftforge.items.wrapper.CombinedInvWrapper; //导入依赖的package包/类
@Override
protected void onContentsChanged(int slot) {
    if (te.getWorld().isRemote || slot != CHARGE_INVENTORY_INDEX) return;

    if (te.chargeableInventory != null) {
        te.chargeableInventory.saveInventory();
        te.setChargeableInventory(null);
    }

    ItemStack stack = getStackInSlot(slot);
    if (stack.getItem() instanceof IChargingStationGUIHolderItem) {
        te.chargeableInventory = new ChargeableItemHandler(te);
        te.invWrapper = new CombinedInvWrapper(te.inventory, te.chargeableInventory);
    }
    List<EntityPlayer> players = te.getWorld().playerEntities;
    for(EntityPlayer player : players) {
        if (player.openContainer instanceof ContainerChargingStationItemInventory && ((ContainerChargingStationItemInventory) player.openContainer).te == te) {
            if (stack.getItem() instanceof IChargingStationGUIHolderItem) {
                // player.openGui(PneumaticCraft.instance, CommonProxy.GUI_ID_PNEUMATIC_ARMOR, getWorld(), getPos().getX(), getPos().getY(), getPos().getZ());
            } else {
                player.openGui(PneumaticCraftRepressurized.instance, EnumGuiId.CHARGING_STATION.ordinal(), te.getWorld(), te.getPos().getX(), te.getPos().getY(), te.getPos().getZ());
            }
        }
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:26,代码来源:TileEntityChargingStation.java

示例2: getItemHandlerCapability

import net.minecraftforge.items.wrapper.CombinedInvWrapper; //导入依赖的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

示例3: handlerForSide

import net.minecraftforge.items.wrapper.CombinedInvWrapper; //导入依赖的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

示例4: ItemHandlerFurnace

import net.minecraftforge.items.wrapper.CombinedInvWrapper; //导入依赖的package包/类
public ItemHandlerFurnace(TileEntityIronFurnace tile)
{
    super(tile.getType().getNumSlots());

    this.tile = tile;
    type = tile.getType();

    fuelHandler = type.fuelSlots > 0
                  ? new ItemHandlerMoveStacks(this,
                                              type.getFirstFuelSlot(),
                                              type.getLastFuelSlot(),
                                              0)
                  : new EmptyHandler();
    inputHandlers = new ItemHandlerMoveStacks[type.parallelSmelting];
    outputHandlers = new ItemHandlerMoveStacks[type.parallelSmelting];

    for (int i = 0; i < type.parallelSmelting; i++)
    {
        inputHandlers[i] = new ItemHandlerMoveStacks(this,
                                                     type.getFirstInputSlot(i),
                                                     type.getLastInputSlot(i),
                                                     0);

        int firstOutput = type.getFirstOutputSlot(i);
        int lastOutput = type.getLastOutputSlot(i);
        outputHandlers[i] = new ItemHandlerMoveStacks(this,
                                                      firstOutput, lastOutput,
                                                      range(1, lastOutput - firstOutput + 1));
    }

    bottomSideHandler = createBottomSideHandler();
    topSideHandler = new CombinedInvWrapper(inputHandlers);
    sidesSideHandler = fuelHandler;
}
 
开发者ID:cubex2,项目名称:morefurnaces,代码行数:35,代码来源:ItemHandlerFurnace.java

示例5: createBottomSideHandler

import net.minecraftforge.items.wrapper.CombinedInvWrapper; //导入依赖的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

示例6: addPlayerSlots

import net.minecraftforge.items.wrapper.CombinedInvWrapper; //导入依赖的package包/类
public GenericContainer addPlayerSlots(final InventoryPlayer playerInv, final Set<Integer> lockedSlots) {
	playerSlotsStart = inventorySlots.size();
	CombinedInvWrapper playerItemHandler =
			new CombinedInvWrapper(new PlayerMainInvWrapper(playerInv), new PlayerOffhandInvWrapper(playerInv));
	addSlots(playerItemHandler, 9, 8, 84, 9, 3);
	addSlots(8, 142, 9, 1, (slot, x, y) -> {
		if (lockedSlots.contains(slot))
			return new SlotLocked(playerItemHandler, slot, x, y);
		else
			return new SlotItemHandlerBase(playerItemHandler, slot, x, y);
	});
	return this;
}
 
开发者ID:hea3ven,项目名称:CommonUtils,代码行数:14,代码来源:GenericContainer.java

示例7: addOneSetOfRecipeItemsIntoGrid

import net.minecraftforge.items.wrapper.CombinedInvWrapper; //导入依赖的package包/类
/**
 * Adds one more of each item in the recipe into the crafting grid, if possible
 * @param invId
 * @param recipeId
 */
protected boolean addOneSetOfRecipeItemsIntoGrid(IItemHandler invCrafting, int invId, int recipeId, EntityPlayer player)
{
    invId = MathHelper.clamp(invId, 0, 1);
    int maskOreDict = invId == 1 ? MODE_BIT_RIGHT_CRAFTING_OREDICT : MODE_BIT_LEFT_CRAFTING_OREDICT;
    boolean useOreDict = (this.modeMask & maskOreDict) != 0;

    IItemHandlerModifiable playerInv = (IItemHandlerModifiable) player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP);
    IItemHandler invWrapper = new CombinedInvWrapper(this.itemInventory, playerInv);

    NonNullList<ItemStack> template = this.getRecipeItems(invId);
    InventoryUtils.clearInventoryToMatchTemplate(invCrafting, invWrapper, template);

    return InventoryUtils.restockInventoryBasedOnTemplate(invCrafting, invWrapper, template, 1, true, useOreDict);
}
 
开发者ID:maruohon,项目名称:enderutilities,代码行数:20,代码来源:TileEntityCreationStation.java

示例8: fillCraftingGrid

import net.minecraftforge.items.wrapper.CombinedInvWrapper; //导入依赖的package包/类
protected void fillCraftingGrid(IItemHandler invCrafting, int invId, int recipeId, EntityPlayer player)
{
    invId = MathHelper.clamp(invId, 0, 1);
    int largestStack = InventoryUtils.getLargestExistingStackSize(invCrafting);

    // If all stacks only have one item, then try to fill them all the way to maxStackSize
    if (largestStack == 1)
    {
        largestStack = 64;
    }

    NonNullList<ItemStack> template = InventoryUtils.createInventorySnapshot(invCrafting);
    int maskOreDict = invId == 1 ? MODE_BIT_RIGHT_CRAFTING_OREDICT : MODE_BIT_LEFT_CRAFTING_OREDICT;
    boolean useOreDict = (this.modeMask & maskOreDict) != 0;

    Map<ItemType, Integer> slotCounts = InventoryUtils.getSlotCountPerItem(invCrafting);

    // Clear old contents and then fill all the slots back up
    if (InventoryUtils.tryMoveAllItems(invCrafting, this.itemInventory) == InvResult.MOVED_ALL)
    {
        IItemHandlerModifiable playerInv = (IItemHandlerModifiable) player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP);
        IItemHandler invWrapper = new CombinedInvWrapper(this.itemInventory, playerInv);

        // Next we find out how many items we have available for each item type on the crafting grid
        // and we cap the max stack size to that value, so the stacks will be balanced
        Iterator<Entry<ItemType, Integer>> iter = slotCounts.entrySet().iterator();

        while (iter.hasNext())
        {
            Entry<ItemType, Integer> entry = iter.next();
            ItemType item = entry.getKey();

            if (item.getStack().getMaxStackSize() == 1)
            {
                continue;
            }

            int numFound = InventoryUtils.getNumberOfMatchingItemsInInventory(invWrapper, item.getStack(), useOreDict);
            int numSlots = entry.getValue();
            int maxSize = numFound / numSlots;

            if (maxSize < largestStack)
            {
                largestStack = maxSize;
            }
        }

        InventoryUtils.restockInventoryBasedOnTemplate(invCrafting, invWrapper, template, largestStack, false, useOreDict);
    }
}
 
开发者ID:maruohon,项目名称:enderutilities,代码行数:51,代码来源:TileEntityCreationStation.java


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