package powercrystals.minefactoryreloaded.gui.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import powercrystals.minefactoryreloaded.gui.slot.SlotRemoveOnly;
import powercrystals.minefactoryreloaded.tile.machine.TileEntityAutoAnvil;
public class ContainerAutoAnvil extends ContainerFactoryPowered
{
public ContainerAutoAnvil(TileEntityAutoAnvil anvil, InventoryPlayer inv)
{
super(anvil, inv);
}
@Override
protected void addSlots()
{
addSlotToContainer(new Slot(_te, 0, 8, 24));
addSlotToContainer(new Slot(_te, 1, 26, 24));
addSlotToContainer(new SlotRemoveOnly(_te, 2, 8, 54));
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot)
{
ItemStack stack = null;
Slot slotObject = (Slot) inventorySlots.get(slot);
if(slotObject != null && slotObject.getHasStack())
{
ItemStack stackInSlot = slotObject.getStack();
stack = stackInSlot.copy();
if(slot < 4)
{
if(!mergeItemStack(stackInSlot, 4, inventorySlots.size(), true))
{
return null;
}
}
else if(!mergeItemStack(stackInSlot, 0, 2, false))
{
return null;
}
if(stackInSlot.stackSize == 0)
{
slotObject.putStack(null);
}
else
{
slotObject.onSlotChanged();
}
if(stackInSlot.stackSize == stack.stackSize)
{
return null;
}
slotObject.onPickupFromSlot(player, stackInSlot);
}
return stack;
}
}