package net.minecraft.inventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; public class ContainerChest extends Container { private IInventory lowerChestInventory; private int numRows; private static final String __OBFID = "CL_00001742"; public ContainerChest(IInventory p_i1806_1_, IInventory p_i1806_2_) { this.lowerChestInventory = p_i1806_2_; this.numRows = p_i1806_2_.getSizeInventory() / 9; p_i1806_2_.openChest(); int i = (this.numRows - 4) * 18; int j; int k; for (j = 0; j < this.numRows; ++j) { for (k = 0; k < 9; ++k) { this.addSlotToContainer(new Slot(p_i1806_2_, k + j * 9, 8 + k * 18, 18 + j * 18)); } } for (j = 0; j < 3; ++j) { for (k = 0; k < 9; ++k) { this.addSlotToContainer(new Slot(p_i1806_1_, k + j * 9 + 9, 8 + k * 18, 103 + j * 18 + i)); } } for (j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(p_i1806_1_, j, 8 + j * 18, 161 + i)); } } public boolean canInteractWith(EntityPlayer player) { return this.lowerChestInventory.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 < this.numRows * 9) { if (!this.mergeItemStack(itemstack1, this.numRows * 9, this.inventorySlots.size(), true)) { return null; } } else if (!this.mergeItemStack(itemstack1, 0, this.numRows * 9, false)) { return null; } if (itemstack1.stackSize == 0) { slot.putStack((ItemStack)null); } else { slot.onSlotChanged(); } } return itemstack; } /** * Called when the container is closed. */ public void onContainerClosed(EntityPlayer p_75134_1_) { super.onContainerClosed(p_75134_1_); this.lowerChestInventory.closeChest(); } /** * Return this chest container's lower chest inventory. */ public IInventory getLowerChestInventory() { return this.lowerChestInventory; } }