Example usage for net.minecraftforge.items SlotItemHandler SlotItemHandler

List of usage examples for net.minecraftforge.items SlotItemHandler SlotItemHandler

Introduction

In this page you can find the example usage for net.minecraftforge.items SlotItemHandler SlotItemHandler.

Prototype

public SlotItemHandler(IItemHandler itemHandler, int index, int xPosition, int yPosition) 

Source Link

Usage

From source file:buildcraft.additionalpipes.gui.ContainerAdvancedWoodPipe.java

License:Open Source License

public ContainerAdvancedWoodPipe(EntityPlayer player, IInventory playerInventory, PipeBehaviorAdvWood pipe) {
    super(player);
    this.pipe = pipe;
    exclude = !pipe.getExclude(); // force a network update
    int k = 0;/*  w ww.ja va2s  .c  o  m*/

    for (int j1 = 0; j1 < 9; j1++) {
        addSlotToContainer(
                new SlotItemHandler(pipe.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null),
                        j1 + k * 9, 8 + j1 * 18, 18 + k * 18));
    }

    for (int l = 0; l < 3; l++) {
        for (int k1 = 0; k1 < 9; k1++) {
            addSlotToContainer(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 76 + l * 18));
        }

    }

    for (int i1 = 0; i1 < 9; i1++) {
        addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 134));
    }
}

From source file:com.gmail.socraticphoenix.forge.randore.crafting.forge.CraftiniumForgeContainer.java

License:Open Source License

public CraftiniumForgeContainer(CraftiniumForgeTileEntity tileEntity, InventoryPlayer playerInventory) {
    this.tileEntity = tileEntity;
    this.player = playerInventory.player;
    this.world = tileEntity.getWorld();
    this.forge = tileEntity.getPos();
    this.addSlotToContainer(new SlotItemHandler(tileEntity.getInput(), 0, 56, 17));
    this.addSlotToContainer(new SlotItemHandler(tileEntity.getFuel(), 0, 56, 53));
    this.addSlotToContainer(new SlotItemHandler(tileEntity.getOutput(), 0, 116, 35));

    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 9; ++j) {
            this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
        }/*  w  ww  . jav a 2 s. c om*/
    }

    for (int k = 0; k < 9; ++k) {
        this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142));
    }
}

From source file:com.teambr.bookshelf.common.container.BaseContainer.java

License:Creative Commons License

/**
 * Adds a line of inventory slots with a margin around them
 *
 * @param xOffset X Offset// ww w.ja  v  a  2  s . c  o  m
 * @param yOffset Y Offset
 * @param start The start slot id
 * @param count The count of slots
 * @param margin How much to pad the slots
 */
protected void addInventoryLine(int xOffset, int yOffset, int start, int count, int margin) {
    int slotID = start;
    for (int x = 0; x < count; x++) {
        addSlotToContainer(new SlotItemHandler(inventory, slotID, xOffset + x * (18 + margin), yOffset));
        slotID++;
    }
}

From source file:com.teambr.bookshelf.common.container.BaseContainer.java

License:Creative Commons License

/**
 * Adds an inventory grid to the container
 *
 * @param xOffset X pixel offset/*from   ww w  . j  a  v a 2  s .com*/
 * @param yOffset Y pixel offset
 * @param width How many wide
 * @param start The start slot id
 */
protected void addInventoryGrid(int xOffset, int yOffset, int width, int start) {
    int height = (int) Math.ceil(inventorySize / width);
    int slotID = start;
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            addSlotToContainer(new SlotItemHandler(inventory, slotID, xOffset + x * 18, yOffset + y * 18));
            slotID++;
        }
    }
}

From source file:com.teambr.modularsystems.core.common.container.ContainerBlockValueConfig.java

License:Creative Commons License

public ContainerBlockValueConfig(IInventory playerInventory) {
    super(playerInventory, new InventoryBlockConfig(null));

    ((InventoryBlockConfig) inventory()).setContainer(this);

    addSlotToContainer(new SlotItemHandler(inventory(), 0, 8, 8));

    addPlayerInventorySlots(8, 120);//from w ww .ja  va 2s .c  om
}

From source file:com.teambrmodding.assistedprogression.common.container.GrinderContainer.java

License:Creative Commons License

/**
 * Creates the container object//www.j a  v a2s . c o  m
 *
 * @param id
 * @param playerInventory The players inventory
 * @param inventory       The tile/object inventory
 */
public GrinderContainer(int id, IInventory playerInventory, IItemHandler inventory) {
    super(ContainerManager.grinder, id, playerInventory, inventory);
    addInventoryLine(62, 19, 0, 3);
    addSlot(new SlotItemHandler(inventory, 3, 80, 38) {
        @Override
        public boolean isItemValid(@Nonnull ItemStack stack) {
            return false;
        }
    });
    this.tile = (GrinderTile) inventory;
    addInventoryLine(62, 57, 4, 3);
    addPlayerInventorySlots(8, 84);
}

From source file:com.teambrmodding.neotech.common.container.machines.ContainerAbstractMachine.java

License:Creative Commons License

/**
 * Creates the object//w  ww .  j a  v a2 s . c om
 *
 * @param playerInventory The players inventory
 * @param inventory       The tile/object inventory
 */
public ContainerAbstractMachine(InventoryPlayer playerInventory, AbstractMachine inventory) {
    super(playerInventory, inventory);
    abstractMachine = inventory;

    // Manage upgrade slots
    upgradeSlots = new ArrayList<>();
    for (int id = 0; id < abstractMachine.upgradeInventory.inventoryContents.size(); id++) {
        SlotItemHandler slot = new SlotItemHandler(abstractMachine.upgradeInventory, id, -1000, -1000) {
            /**
             * Check if the stack is a valid item for this slot. Always true beside for the armor slots.
             *
             * @param stack
             */
            @Override
            public boolean isItemValid(ItemStack stack) {
                return !abstractMachine.hasUpgradeAlready(stack)
                        && stack.hasCapability(CapabilityLoadManager.UPGRADE_ITEM_CAPABILITY, null);
            }
        };
        upgradeSlots.add(slot);
        addSlotToContainer(slot);
    }
}

From source file:com.teambrmodding.neotech.common.container.machines.generators.ContainerFluidGenerator.java

License:Creative Commons License

/**
 * Creates the object/*from   w  w  w.j a va 2s .c  o m*/
 *
 * @param playerInventory The players inventory
 * @param inventory       The tile/object inventory
 */
public ContainerFluidGenerator(InventoryPlayer playerInventory, AbstractMachine inventory) {
    super(playerInventory, inventory);

    // Fluid Handler In
    addSlotToContainer(new SlotItemHandler(inventory, 0, 123, 12) {
        @Nullable
        @Override
        public String getSlotTexture() {
            GlStateManager.enableBlend();
            return "neotech:gui/in";
        }
    });

    // Fluid Handler Out
    addSlotToContainer(new SlotItemHandler(inventory, 1, 123, 58) {
        @Nullable
        @Override
        public String getSlotTexture() {
            GlStateManager.enableBlend();
            return "neotech:gui/out";
        }
    });

    addPlayerInventorySlots(84);
}

From source file:com.teambrmodding.neotech.common.container.machines.generators.ContainerFurnaceGenerator.java

License:Creative Commons License

/**
 * Creates the object/*from   ww w  .  ja va 2s. c  om*/
 *
 * @param playerInventory The players inventory
 * @param inventory       The tile/object inventory
 */
public ContainerFurnaceGenerator(InventoryPlayer playerInventory, AbstractMachine inventory) {
    super(playerInventory, inventory);

    addSlotToContainer(new SlotItemHandler(inventory, 0, 80, 58));
    addPlayerInventorySlots(84);
}

From source file:com.teambrmodding.neotech.common.container.machines.operators.ContainerTreeFarm.java

License:Creative Commons License

/**
 * Creates the object/*ww  w  .j  a  v a  2s. co m*/
 *
 * @param playerInventory The players inventory
 * @param inventory       The tile/object inventory
 */
public ContainerTreeFarm(InventoryPlayer playerInventory, TileTreeFarm inventory) {
    super(playerInventory, inventory);

    // Add Tool Slots
    addSlotToContainer(new SlotItemHandler(inventory, TileTreeFarm.AXE_SLOT, 62, 20) {
        /**
         * Check if the stack is a valid item for this slot. Always true beside for the armor slots.
         */
        @Override
        public boolean isItemValid(ItemStack stack) {
            return stack.getItem() instanceof ItemTool || stack.getItem().getToolClasses(stack).contains("axe");
        }

        @Nullable
        @Override
        public String getSlotTexture() {
            GlStateManager.enableBlend();
            return "neotech:items/axe_ghost";
        }
    });
    addSlotToContainer(new SlotItemHandler(inventory, TileTreeFarm.SHEARS_SLOT, 89, 20) {
        /**
         * Check if the stack is a valid item for this slot. Always true beside for the armor slots.
         */
        @Override
        public boolean isItemValid(ItemStack stack) {
            return stack.getItem() instanceof ItemShears;
        }

        @Nullable
        @Override
        public String getSlotTexture() {
            GlStateManager.enableBlend();
            return "neotech:items/shears_ghost";
        }
    });

    // Add Inventory Slots
    addInventoryLine(62, 40, 3, 6);
    addInventoryLine(62, 58, 9, 6);

    // Add sapling slots
    addInventoryLine(116, 20, 15, 3);

    // Add player slots
    addPlayerInventorySlots(84);
}