    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005
    006    public class ContainerBeacon extends Container
    007    {
    008        private TileEntityBeacon field_82866_e;
    009        private final SlotBeacon field_82864_f;
    010        private int field_82865_g;
    011        private int field_82867_h;
    012        private int field_82868_i;
    013
    014        public ContainerBeacon(InventoryPlayer par1InventoryPlayer, TileEntityBeacon par2TileEntityBeacon)
    015        {
    016            this.field_82866_e = par2TileEntityBeacon;
    017            this.addSlotToContainer(this.field_82864_f = new SlotBeacon(this, par2TileEntityBeacon, 0, 136, 110));
    018            byte var3 = 36;
    019            short var4 = 137;
    020            int var5;
    021
    022            for (var5 = 0; var5 < 3; ++var5)
    023            {
    024                for (int var6 = 0; var6 < 9; ++var6)
    025                {
    026                    this.addSlotToContainer(new Slot(par1InventoryPlayer, var6 + var5 * 9 + 9, var3 + var6 * 18, var4 + var5 * 18));
    027                }
    028            }
    029
    030            for (var5 = 0; var5 < 9; ++var5)
    031            {
    032                this.addSlotToContainer(new Slot(par1InventoryPlayer, var5, var3 + var5 * 18, 58 + var4));
    033            }
    034
    035            this.field_82865_g = par2TileEntityBeacon.func_82130_k();
    036            this.field_82867_h = par2TileEntityBeacon.func_82126_i();
    037            this.field_82868_i = par2TileEntityBeacon.func_82132_j();
    038        }
    039
    040        public void addCraftingToCrafters(ICrafting par1ICrafting)
    041        {
    042            super.addCraftingToCrafters(par1ICrafting);
    043            par1ICrafting.updateCraftingInventoryInfo(this, 0, this.field_82865_g);
    044            par1ICrafting.updateCraftingInventoryInfo(this, 1, this.field_82867_h);
    045            par1ICrafting.updateCraftingInventoryInfo(this, 2, this.field_82868_i);
    046        }
    047
    048        /**
    049         * Updates crafting matrix; called from onCraftMatrixChanged. Args: none
    050         */
    051        public void updateCraftingResults()
    052        {
    053            super.updateCraftingResults();
    054        }
    055
    056        @SideOnly(Side.CLIENT)
    057        public void updateProgressBar(int par1, int par2)
    058        {
    059            if (par1 == 0)
    060            {
    061                this.field_82866_e.func_82129_c(par2);
    062            }
    063
    064            if (par1 == 1)
    065            {
    066                this.field_82866_e.func_82128_d(par2);
    067            }
    068
    069            if (par1 == 2)
    070            {
    071                this.field_82866_e.func_82127_e(par2);
    072            }
    073        }
    074
    075        public TileEntityBeacon func_82863_d()
    076        {
    077            return this.field_82866_e;
    078        }
    079
    080        public boolean canInteractWith(EntityPlayer par1EntityPlayer)
    081        {
    082            return this.field_82866_e.isUseableByPlayer(par1EntityPlayer);
    083        }
    084
    085        public ItemStack func_82846_b(EntityPlayer par1EntityPlayer, int par2)
    086        {
    087            ItemStack var3 = null;
    088            Slot var4 = (Slot)this.inventorySlots.get(par2);
    089
    090            if (var4 != null && var4.getHasStack())
    091            {
    092                ItemStack var5 = var4.getStack();
    093                var3 = var5.copy();
    094
    095                if (par2 == 0)
    096                {
    097                    if (!this.mergeItemStack(var5, 1, 37, true))
    098                    {
    099                        return null;
    100                    }
    101
    102                    var4.onSlotChange(var5, var3);
    103                }
    104                else if (!this.field_82864_f.getHasStack() && this.field_82864_f.isItemValid(var5) && var5.stackSize == 1)
    105                {
    106                    if (!this.mergeItemStack(var5, 0, 1, false))
    107                    {
    108                        return null;
    109                    }
    110                }
    111                else if (par2 >= 1 && par2 < 28)
    112                {
    113                    if (!this.mergeItemStack(var5, 28, 37, false))
    114                    {
    115                        return null;
    116                    }
    117                }
    118                else if (par2 >= 28 && par2 < 37)
    119                {
    120                    if (!this.mergeItemStack(var5, 1, 28, false))
    121                    {
    122                        return null;
    123                    }
    124                }
    125                else if (!this.mergeItemStack(var5, 1, 37, false))
    126                {
    127                    return null;
    128                }
    129
    130                if (var5.stackSize == 0)
    131                {
    132                    var4.putStack((ItemStack)null);
    133                }
    134                else
    135                {
    136                    var4.onSlotChanged();
    137                }
    138
    139                if (var5.stackSize == var3.stackSize)
    140                {
    141                    return null;
    142                }
    143
    144                var4.func_82870_a(par1EntityPlayer, var5);
    145            }
    146
    147            return var3;
    148        }
    149    }