public class BlockTestContainer extends Container {
public BlockTestTile testTile;
private int z=0;
public BlockTestContainer(InventoryPlayer player,BlockTestTile tile){
testTile=tile;
addSlotToContainer(new TestSlot(tile,0,79,40));//8+4*18 8 -отступ от края, 18-длина одной ячейки
int i;
for (i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i)
{
this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) {
ItemStack itemstack = null;
Slot slot = (Slot)this.inventorySlots.get(fromSlot);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (fromSlot < 9)
{
if (!this.mergeItemStack(itemstack1, 9, this.inventorySlots.size(), true))
{
return null;
}
}
else if (!this.mergeItemStack(itemstack1, 0, 9, false))
{
return null;
}
// BlockTestGuiHandler
if (itemstack1.stackSize == 0)
{
slot.putStack((ItemStack)null);
}
else
{
slot.onSlotChanged();
}
}
return itemstack;
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return testTile.isUseableByPlayer(player);
}
}