package net.minecraft.inventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; public class ContainerHopper extends Container { private final IInventory field_94538_a; private static final String __OBFID = "CL_00001750"; public ContainerHopper(InventoryPlayer p_i1814_1_, IInventory p_i1814_2_) { this.field_94538_a = p_i1814_2_; p_i1814_2_.openChest(); byte b0 = 51; int i; for (i = 0; i < p_i1814_2_.getSizeInventory(); ++i) { this.addSlotToContainer(new Slot(p_i1814_2_, i, 44 + i * 18, 20)); } for (i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(p_i1814_1_, j + i * 9 + 9, 8 + j * 18, i * 18 + b0)); } } for (i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(p_i1814_1_, i, 8 + i * 18, 58 + b0)); } } public boolean canInteractWith(EntityPlayer player) { return this.field_94538_a.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.field_94538_a.getSizeInventory()) { if (!this.mergeItemStack(itemstack1, this.field_94538_a.getSizeInventory(), this.inventorySlots.size(), true)) { return null; } } else if (!this.mergeItemStack(itemstack1, 0, this.field_94538_a.getSizeInventory(), 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.field_94538_a.closeChest(); } }