package com.mcgoodtime.gti.common.inventory;

import com.mcgoodtime.gti.common.tiles.TileContainer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;

/**
 * Created by BestOwl on 2015.10.31.0031.
 *
 * Gti base container.
 * @author BestOwl
 */
public abstract class ContainerGti<T extends IInventory> extends Container {

    public T tile;

    public ContainerGti(EntityPlayer player, T tile) {
        this.tile = tile;
        int i;
        for (i = 0; i < 3; ++i) {
            for (int j = 0; j < 9; ++j) {
                this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
            }
        }
        for (i = 0; i < 9; ++i) {
            this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
        }
    }

    @SuppressWarnings("unchecked")
    @Override
    protected final Slot addSlotToContainer(Slot slot) {
        int num = this.tile.getSizeInventory();

        while (this.inventorySlots.size() < num) {
            this.inventorySlots.add(null);
            this.inventoryItemStacks.add(null);
        }
        if (slot.inventory instanceof TileContainer) {
            slot.slotNumber = slot.getSlotIndex();
            this.inventorySlots.set(slot.getSlotIndex(), slot);
        } else {
            slot.slotNumber = this.inventorySlots.size();
            this.inventorySlots.add(slot);
            this.inventoryItemStacks.add(null);
        }
        return slot;
    }

    @Override
    public boolean canInteractWith(EntityPlayer player) {
        return this.tile.isUseableByPlayer(player);
    }

    public T getTileEntity() {
        return this.tile;
    }
}

@@ -85,32 +85,64 @@
 .TileContainer;%0A
+import ic2.core.util.StackUtil;%0A
 import net.minec
@@ -295,16 +295,53 @@
 ry.Slot;
+%0Aimport net.minecraft.item.ItemStack;
 %0A%0A/**%0A *
@@ -1842,11 +1842,1126 @@
 e;%0A    %7D
+%0A%0A    public boolean transferItemStack(ItemStack item, Slot slot) %7B%0A        int max = Math.min(item.getMaxStackSize(), slot.getSlotStackLimit());%0A        max = Math.min(max, slot.inventory.getInventoryStackLimit());%0A        ItemStack slotItem = slot.getStack();%0A%0A        if (slotItem != null) %7B%0A            if (!item.isItemEqual(slotItem)) %7B%0A                return false;%0A            %7D%0A%0A            int i = this.getTransferAmount(item.stackSize, slotItem.stackSize, max);%0A            slotItem.stackSize += i;%0A            item.stackSize -= i;%0A            return true;%0A        %7D%0A        else %7B%0A            int i = this.getTransferAmount(item.stackSize, 0, max);%0A            slot.putStack(StackUtil.copyWithSize(item, i));%0A            item.stackSize -= i;%0A            return true;%0A        %7D%0A    %7D%0A%0A    private int getTransferAmount(int amount, int currentAmount, int maxAmount) %7B%0A        if (amount %3C= maxAmount) %7B%0A            if (amount + currentAmount %3E maxAmount) %7B%0A                return maxAmount - currentAmount;%0A            %7D else %7B%0A                return amount;%0A            %7D%0A        %7D%0A        return 0;%0A    %7D
 %0A%7D%0A

Add transferItemStack method