/// <summary>
        /// Called whenever the block is removed.
        /// </summary>
        public override void OnBlockRemoval(World par1World, int par2, int par3, int par4)
        {
            TileEntity tileentity = par1World.GetBlockTileEntity(par2, par3, par4);

            if (tileentity != null && (tileentity is TileEntityBrewingStand))
            {
                TileEntityBrewingStand tileentitybrewingstand = (TileEntityBrewingStand)tileentity;
label0:

                for (int i = 0; i < tileentitybrewingstand.GetSizeInventory(); i++)
                {
                    ItemStack itemstack = tileentitybrewingstand.GetStackInSlot(i);

                    if (itemstack == null)
                    {
                        continue;
                    }

                    float f  = Rand.NextFloat() * 0.8F + 0.1F;
                    float f1 = Rand.NextFloat() * 0.8F + 0.1F;
                    float f2 = Rand.NextFloat() * 0.8F + 0.1F;

                    do
                    {
                        if (itemstack.StackSize <= 0)
                        {
                            goto label0;
                        }

                        int j = Rand.Next(21) + 10;

                        if (j > itemstack.StackSize)
                        {
                            j = itemstack.StackSize;
                        }

                        itemstack.StackSize -= j;
                        EntityItem entityitem = new EntityItem(par1World, (float)par2 + f, (float)par3 + f1, (float)par4 + f2, new ItemStack(itemstack.ItemID, j, itemstack.GetItemDamage()));
                        float      f3         = 0.05F;
                        entityitem.MotionX = (float)Rand.NextGaussian() * f3;
                        entityitem.MotionY = (float)Rand.NextGaussian() * f3 + 0.2F;
                        entityitem.MotionZ = (float)Rand.NextGaussian() * f3;
                        par1World.SpawnEntityInWorld(entityitem);
                    }while (true);
                }
            }

            base.OnBlockRemoval(par1World, par2, par3, par4);
        }
        /// <summary>
        /// Called upon block activation (left or right click on the block.). The three integers represent x,y,z of the
        /// block.
        /// </summary>
        public override bool BlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
        {
            if (par1World.IsRemote)
            {
                return(true);
            }

            TileEntityBrewingStand tileentitybrewingstand = (TileEntityBrewingStand)par1World.GetBlockTileEntity(par2, par3, par4);

            if (tileentitybrewingstand != null)
            {
                par5EntityPlayer.DisplayGUIBrewingStand(tileentitybrewingstand);
            }

            return(true);
        }
 /// <summary>
 /// Displays the GUI for interacting with a brewing stand.
 /// </summary>
 public override void DisplayGUIBrewingStand(TileEntityBrewingStand par1TileEntityBrewingStand)
 {
     Mc.DisplayGuiScreen(new GuiBrewingStand(Inventory, par1TileEntityBrewingStand));
 }
Esempio n. 4
0
 public GuiBrewingStand(InventoryPlayer par1InventoryPlayer, TileEntityBrewingStand par2TileEntityBrewingStand) : base(new ContainerBrewingStand(par1InventoryPlayer, par2TileEntityBrewingStand))
 {
     Field_40217_h = par2TileEntityBrewingStand;
 }