package net.minecraft.inventory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityDispenser;
public class ContainerDispenser extends Container
{
private TileEntityDispenser tileEntityDispenser;
private static final String __OBFID = "CL_00001763";
public ContainerDispenser(IInventory p_i1825_1_, TileEntityDispenser p_i1825_2_)
{
this.tileEntityDispenser = p_i1825_2_;
int i;
int j;
for (i = 0; i < 3; ++i)
{
for (j = 0; j < 3; ++j)
{
this.addSlotToContainer(new Slot(p_i1825_2_, j + i * 3, 62 + j * 18, 17 + i * 18));
}
}
for (i = 0; i < 3; ++i)
{
for (j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(p_i1825_1_, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i)
{
this.addSlotToContainer(new Slot(p_i1825_1_, i, 8 + i * 18, 142));
}
}
public boolean canInteractWith(EntityPlayer player)
{
return this.tileEntityDispenser.isUseableByPlayer(player);
}
/**
* Take a stack from the specified inventory slot.
*/
public ItemStack transferStackInSlot(EntityPlayer player, int index)
{
ItemStack itemstack = null;
Slot slot = (Slot)this.inventorySlots.get(index);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (index < 9)
{
if (!this.mergeItemStack(itemstack1, 9, 45, true))
{
return null;
}
}
else if (!this.mergeItemStack(itemstack1, 0, 9, false))
{
return null;
}
if (itemstack1.stackSize == 0)
{
slot.putStack((ItemStack)null);
}
else
{
slot.onSlotChanged();
}
if (itemstack1.stackSize == itemstack.stackSize)
{
return null;
}
slot.onPickupFromSlot(player, itemstack1);
}
return itemstack;
}
}