    001    package net.minecraft.src;
    002
    003    public class InventoryLargeChest implements IInventory
    004    {
    005        /** Name of the chest. */
    006        private String name;
    007
    008        /** Inventory object corresponding to double chest upper part */
    009        private IInventory upperChest;
    010
    011        /** Inventory object corresponding to double chest lower part */
    012        private IInventory lowerChest;
    013
    014        public InventoryLargeChest(String par1Str, IInventory par2IInventory, IInventory par3IInventory)
    015        {
    016            this.name = par1Str;
    017
    018            if (par2IInventory == null)
    019            {
    020                par2IInventory = par3IInventory;
    021            }
    022
    023            if (par3IInventory == null)
    024            {
    025                par3IInventory = par2IInventory;
    026            }
    027
    028            this.upperChest = par2IInventory;
    029            this.lowerChest = par3IInventory;
    030        }
    031
    032        /**
    033         * Returns the number of slots in the inventory.
    034         */
    035        public int getSizeInventory()
    036        {
    037            return this.upperChest.getSizeInventory() + this.lowerChest.getSizeInventory();
    038        }
    039
    040        public boolean func_90010_a(IInventory par1IInventory)
    041        {
    042            return this.upperChest == par1IInventory || this.lowerChest == par1IInventory;
    043        }
    044
    045        /**
    046         * Returns the name of the inventory.
    047         */
    048        public String getInvName()
    049        {
    050            return this.name;
    051        }
    052
    053        /**
    054         * Returns the stack in slot i
    055         */
    056        public ItemStack getStackInSlot(int par1)
    057        {
    058            return par1 >= this.upperChest.getSizeInventory() ? this.lowerChest.getStackInSlot(par1 - this.upperChest.getSizeInventory()) : this.upperChest.getStackInSlot(par1);
    059        }
    060
    061        /**
    062         * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a
    063         * new stack.
    064         */
    065        public ItemStack decrStackSize(int par1, int par2)
    066        {
    067            return par1 >= this.upperChest.getSizeInventory() ? this.lowerChest.decrStackSize(par1 - this.upperChest.getSizeInventory(), par2) : this.upperChest.decrStackSize(par1, par2);
    068        }
    069
    070        /**
    071         * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem -
    072         * like when you close a workbench GUI.
    073         */
    074        public ItemStack getStackInSlotOnClosing(int par1)
    075        {
    076            return par1 >= this.upperChest.getSizeInventory() ? this.lowerChest.getStackInSlotOnClosing(par1 - this.upperChest.getSizeInventory()) : this.upperChest.getStackInSlotOnClosing(par1);
    077        }
    078
    079        /**
    080         * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
    081         */
    082        public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
    083        {
    084            if (par1 >= this.upperChest.getSizeInventory())
    085            {
    086                this.lowerChest.setInventorySlotContents(par1 - this.upperChest.getSizeInventory(), par2ItemStack);
    087            }
    088            else
    089            {
    090                this.upperChest.setInventorySlotContents(par1, par2ItemStack);
    091            }
    092        }
    093
    094        /**
    095         * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't
    096         * this more of a set than a get?*
    097         */
    098        public int getInventoryStackLimit()
    099        {
    100            return this.upperChest.getInventoryStackLimit();
    101        }
    102
    103        /**
    104         * Called when an the contents of an Inventory change, usually
    105         */
    106        public void onInventoryChanged()
    107        {
    108            this.upperChest.onInventoryChanged();
    109            this.lowerChest.onInventoryChanged();
    110        }
    111
    112        /**
    113         * Do not make give this method the name canInteractWith because it clashes with Container
    114         */
    115        public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
    116        {
    117            return this.upperChest.isUseableByPlayer(par1EntityPlayer) && this.lowerChest.isUseableByPlayer(par1EntityPlayer);
    118        }
    119
    120        public void openChest()
    121        {
    122            this.upperChest.openChest();
    123            this.lowerChest.openChest();
    124        }
    125
    126        public void closeChest()
    127        {
    128            this.upperChest.closeChest();
    129            this.lowerChest.closeChest();
    130        }
    131    }