示例#1
0
        /// <summary>
        /// Called whenever the block is removed.
        /// </summary>
        public override void OnBlockRemoval(World par1World, int par2, int par3, int par4)
        {
            if (!KeepFurnaceInventory)
            {
                TileEntityFurnace tileentityfurnace = (TileEntityFurnace)par1World.GetBlockTileEntity(par2, par3, par4);

                if (tileentityfurnace != null)
                {
label0:

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

                        if (itemstack == null)
                        {
                            continue;
                        }

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

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

                            int j = FurnaceRand.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()));

                            if (itemstack.HasTagCompound())
                            {
                                entityitem.ItemStack.SetTagCompound((NBTTagCompound)itemstack.GetTagCompound().Copy());
                            }

                            float f3 = 0.05F;
                            entityitem.MotionX = (float)FurnaceRand.NextGaussian() * f3;
                            entityitem.MotionY = (float)FurnaceRand.NextGaussian() * f3 + 0.2F;
                            entityitem.MotionZ = (float)FurnaceRand.NextGaussian() * f3;
                            par1World.SpawnEntityInWorld(entityitem);
                        }while (true);
                    }
                }
            }

            base.OnBlockRemoval(par1World, par2, par3, par4);
        }
示例#2
0
        /// <summary>
        /// Will get destroyed next tick.
        /// </summary>
        public override void SetDead()
        {
label0:

            for (int i = 0; i < GetSizeInventory(); i++)
            {
                ItemStack itemstack = 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(WorldObj, PosX + f, PosY + f1, PosZ + f2, new ItemStack(itemstack.ItemID, j, itemstack.GetItemDamage()));

                    if (itemstack.HasTagCompound())
                    {
                        entityitem.ItemStack.SetTagCompound((NBTTagCompound)itemstack.GetTagCompound().Copy());
                    }

                    float f3 = 0.05F;
                    entityitem.MotionX = (float)Rand.NextGaussian() * f3;
                    entityitem.MotionY = (float)Rand.NextGaussian() * f3 + 0.2F;
                    entityitem.MotionZ = (float)Rand.NextGaussian() * f3;
                    WorldObj.SpawnEntityInWorld(entityitem);
                }while (true);
            }

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

            if (tileentitychest != null)
            {
                for (int i = 0; i < tileentitychest.GetSizeInventory(); i++)
                {
                    ItemStack itemstack = tileentitychest.GetStackInSlot(i);

                    if (itemstack == null)
                    {
                        continue;
                    }

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

                    while (itemstack.StackSize > 0)
                    {
                        int j = Random.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)Random.NextGaussian() * f3;
                        entityitem.MotionY = (float)Random.NextGaussian() * f3 + 0.2F;
                        entityitem.MotionZ = (float)Random.NextGaussian() * f3;

                        if (itemstack.HasTagCompound())
                        {
                            entityitem.ItemStack.SetTagCompound((NBTTagCompound)itemstack.GetTagCompound().Copy());
                        }

                        par1World.SpawnEntityInWorld(entityitem);
                    }
                }
            }

            base.OnBlockRemoval(par1World, par2, par3, par4);
        }