Example usage for net.minecraftforge.items ItemStackHandler ItemStackHandler

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

Introduction

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

Prototype

public ItemStackHandler(NonNullList<ItemStack> stacks) 

Source Link

Usage

From source file:blusunrize.immersiveengineering.common.gui.ContainerToolboxBlock.java

public ContainerToolboxBlock(InventoryPlayer inventoryPlayer, TileEntityToolbox tile) {
    super(inventoryPlayer, tile);
    this.tile = tile;
    inv = new ItemStackHandler(tile.getInventory());
    if (inv instanceof IEItemStackHandler)
        ((IEItemStackHandler) inv).setTile(tile);
    this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 48, 24));
    this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 30, 42));
    this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 48, 42));

    this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 75, 24));
    this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 93, 24));
    this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 111, 24));
    this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 75, 42));
    this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 93, 42));
    this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 111, 42));
    this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 129, 42));

    for (int j = 0; j < 6; j++)
        this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 35 + j * 18, 77));
    for (int j = 0; j < 7; j++)
        this.addSlotToContainer(new IESlot.ContainerCallback(this, inv, slotCount++, 26 + j * 18, 112));

    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 9; j++)
            this.addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 157 + i * 18));
    for (int i = 0; i < 9; i++)
        this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 215));
}

From source file:com.buuz135.industrial.tile.agriculture.AnimalGrowthIncreaserTile.java

License:Open Source License

@Override
protected void initializeInventories() {
    super.initializeInventories();
    items = new ItemStackHandler(6 * 3) {
        @Override//from  w w w .j ava2 s.c  om
        protected void onContentsChanged(int slot) {
            AnimalGrowthIncreaserTile.this.markDirty();
        }
    };
    this.addInventory(new CustomColoredItemHandler(items, EnumDyeColor.GREEN, "Food items", 18 * 3, 25, 6, 3));
    this.addInventoryToStorage(items, "items");
}

From source file:com.buuz135.industrial.tile.agriculture.AnimalResourceHarvesterTile.java

License:Open Source License

@Override
protected void initializeInventories() {
    super.initializeInventories();
    tank = this.addSimpleFluidTank(8000, "tank", EnumDyeColor.WHITE, 50, 25, FluidTankType.OUTPUT,
            fluidStack -> false, fluidStack -> true);
    outItems = new ItemStackHandler(3 * 4) {
        @Override//from w w  w  .  j  a v  a  2 s.  c o m
        protected void onContentsChanged(int slot) {
            AnimalResourceHarvesterTile.this.markDirty();
        }
    };
    this.addInventory(
            new CustomColoredItemHandler(outItems, EnumDyeColor.ORANGE, "Output Items", 18 * 5 + 3, 25, 4, 3) {
                @Override
                public boolean canInsertItem(int slot, ItemStack stack) {
                    return false;
                }

                @Override
                public boolean canExtractItem(int slot) {
                    return true;
                }
            });
    this.addInventoryToStorage(outItems, "outItems");
}

From source file:com.buuz135.industrial.tile.agriculture.AnimalStockIncreaserTile.java

License:Open Source License

@Override
protected void initializeInventories() {
    super.initializeInventories();
    inFeedItems = new ItemStackHandler(3 * 6) {
        @Override/*from w w w  . j a v  a  2 s .c  o  m*/
        protected void onContentsChanged(int slot) {
            AnimalStockIncreaserTile.this.markDirty();
        }
    };
    this.addInventory(
            new CustomColoredItemHandler(inFeedItems, EnumDyeColor.GREEN, "Food items", 18 * 3, 25, 6, 3) {
                @Override
                public boolean canInsertItem(int slot, ItemStack stack) {
                    return true;
                }

                @Override
                public boolean canExtractItem(int slot) {
                    return false;
                }

            });
    this.addInventoryToStorage(inFeedItems, "animal_stock_in");
}

From source file:com.buuz135.industrial.tile.agriculture.CropEnrichMaterialInjectorTile.java

License:Open Source License

@Override
protected void initializeInventories() {
    super.initializeInventories();
    inFert = new ItemStackHandler(12) {
        @Override// w w w .  java 2  s  . c o m
        protected void onContentsChanged(int slot) {
            CropEnrichMaterialInjectorTile.this.markDirty();
        }
    };
    this.addInventory(
            new CustomColoredItemHandler(inFert, EnumDyeColor.GREEN, "Fertilizer input", 18 * 5 + 3, 25, 4, 3) {
                @Override
                public boolean canInsertItem(int slot, ItemStack stack) {
                    return isValidFertilizer(stack);
                }

                @Override
                public boolean canExtractItem(int slot) {
                    return false;
                }

            });
    this.addInventoryToStorage(inFert, "inFert");
}

From source file:com.buuz135.industrial.tile.agriculture.CropRecolectorTile.java

License:Open Source License

@Override
protected void initializeInventories() {
    super.initializeInventories();
    sludge = this.addFluidTank(FluidsRegistry.SLUDGE, 8000, EnumDyeColor.BLACK, "Sludge tank",
            new BoundingRectangle(50, 25, 18, 54));
    outItems = new ItemStackHandler(3 * 4) {
        @Override//w  ww  .  j a v  a2 s .  c o  m
        protected void onContentsChanged(int slot) {
            CropRecolectorTile.this.markDirty();
        }
    };
    this.addInventory(
            new CustomColoredItemHandler(outItems, EnumDyeColor.ORANGE, "Crops output", 18 * 5 + 3, 25, 4, 3) {
                @Override
                public boolean canInsertItem(int slot, ItemStack stack) {
                    return false;
                }

                @Override
                public boolean canExtractItem(int slot) {
                    return true;
                }

            });
    this.addInventoryToStorage(outItems, "outItems");
}

From source file:com.buuz135.industrial.tile.agriculture.SewageCompostSolidifierTile.java

License:Open Source License

@Override
protected void initializeInventories() {
    super.initializeInventories();
    sewage = this.addFluidTank(FluidsRegistry.SEWAGE, 8000, EnumDyeColor.BROWN, "Sewage tank",
            new BoundingRectangle(50, 25, 18, 54));
    outFertilizer = new ItemStackHandler(4 * 3) {
        @Override//from  w w  w  .j  a  v  a 2  s  . com
        protected void onContentsChanged(int slot) {
            SewageCompostSolidifierTile.this.markDirty();
        }
    };
    this.addInventory(new CustomColoredItemHandler(outFertilizer, EnumDyeColor.ORANGE, "Output Items",
            18 * 5 + 3, 25, 4, 3) {
        @Override
        public boolean canInsertItem(int slot, ItemStack stack) {
            return false;
        }

        @Override
        public boolean canExtractItem(int slot) {
            return true;
        }
    });
    this.addInventoryToStorage(outFertilizer, "outFertilizer");
}

From source file:com.buuz135.industrial.tile.agriculture.SludgeRefinerTile.java

License:Open Source License

@Override
protected void initializeInventories() {
    super.initializeInventories();
    tank = this.addFluidTank(FluidsRegistry.SLUDGE, 8000, EnumDyeColor.BLACK, "Sludge tank",
            new BoundingRectangle(50, 25, 18, 54));
    outItems = new ItemStackHandler(4 * 3) {
        @Override//from w ww  . j  a v  a2s.  c om
        protected void onContentsChanged(int slot) {
            SludgeRefinerTile.this.markDirty();
        }
    };
    this.addInventory(
            new CustomColoredItemHandler(outItems, EnumDyeColor.BROWN, "Output items", 18 * 5 + 3, 25, 4, 3) {
                @Override
                public boolean canInsertItem(int slot, ItemStack stack) {
                    return false;
                }

                @Override
                public boolean canExtractItem(int slot) {
                    return true;
                }
            });
    this.addInventoryToStorage(outItems, "outItems");
}

From source file:com.buuz135.industrial.tile.agriculture.SporesRecreatorTile.java

License:Open Source License

@Override
protected void initializeInventories() {
    super.initializeInventories();
    waterTank = this.addFluidTank(FluidRegistry.WATER, 8000, EnumDyeColor.BLUE, "Water tank",
            new BoundingRectangle(18 * 2 + 13, 25, 18, 54));
    input = new ItemStackHandler(3) {
        @Override/* w  w w. j a v a  2  s . c  om*/
        protected void onContentsChanged(int slot) {
            SporesRecreatorTile.this.markDirty();
        }
    };
    this.addInventory(new CustomColoredItemHandler(input, EnumDyeColor.RED, "Input items", 18 * 5, 25, 1, 3) {
        @Override
        public boolean canInsertItem(int slot, ItemStack stack) {
            Block block = Block.getBlockFromItem(stack.getItem());
            return block.equals(Blocks.BROWN_MUSHROOM) || block.equals(Blocks.RED_MUSHROOM);
        }

        @Override
        public boolean canExtractItem(int slot) {
            return false;
        }
    });
    this.addInventoryToStorage(input, "input");
    output = new ItemStackHandler(9) {
        @Override
        protected void onContentsChanged(int slot) {
            SporesRecreatorTile.this.markDirty();
        }
    };
    this.addInventory(
            new CustomColoredItemHandler(output, EnumDyeColor.ORANGE, "Output items", 18 * 6 + 5, 25, 3, 3) {
                @Override
                public boolean canInsertItem(int slot, ItemStack stack) {
                    return false;
                }

                @Override
                public boolean canExtractItem(int slot) {
                    return true;
                }
            });
    this.addInventoryToStorage(output, "output");
}

From source file:com.buuz135.industrial.tile.agriculture.WaterResourcesCollectorTile.java

License:Open Source License

@Override
protected void initializeInventories() {
    super.initializeInventories();
    outFish = new ItemStackHandler(3 * 6) {
        @Override/*from   ww w .ja  v a2  s  .c  o m*/
        protected void onContentsChanged(int slot) {
            WaterResourcesCollectorTile.this.markDirty();
        }
    };
    this.addInventory(
            new CustomColoredItemHandler(outFish, EnumDyeColor.GREEN, "Fish output", 18 * 3, 25, 6, 3) {
                @Override
                public boolean canInsertItem(int slot, ItemStack stack) {
                    return false;
                }

                @Override
                public boolean canExtractItem(int slot) {
                    return true;
                }
            });
    this.addInventoryToStorage(outFish, "outFish");
}