/// <summary>
 /// Called upon the block being destroyed by an explosion
 /// </summary>
 public override void OnBlockDestroyedByExplosion(World par1World, int par2, int par3, int par4)
 {
     if (par1World.IsRemote)
     {
         return;
     }
     else
     {
         EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(par1World, (float)par2 + 0.5F, (float)par3 + 0.5F, (float)par4 + 0.5F);
         entitytntprimed.Fuse = par1World.Rand.Next(entitytntprimed.Fuse / 4) + entitytntprimed.Fuse / 8;
         par1World.SpawnEntityInWorld(entitytntprimed);
         return;
     }
 }
Example #2
0
        public virtual void Func_153_a(EntityTNTPrimed par1EntityTNTPrimed, double par2, double par4, double par6, float par8, float par9)
        {
            //GL.PushMatrix();
            //GL.Translate((float)par2, (float)par4, (float)par6);

            if (((float)par1EntityTNTPrimed.Fuse - par9) + 1.0F < 10F)
            {
                float f = 1.0F - (((float)par1EntityTNTPrimed.Fuse - par9) + 1.0F) / 10F;

                if (f < 0.0F)
                {
                    f = 0.0F;
                }

                if (f > 1.0F)
                {
                    f = 1.0F;
                }

                f *= f;
                f *= f;
                float f2 = 1.0F + f * 0.3F;
                //GL.Scale(f2, f2, f2);
            }

            float f1 = (1.0F - (((float)par1EntityTNTPrimed.Fuse - par9) + 1.0F) / 100F) * 0.8F;

            LoadTexture("/terrain.png");
            BlockRenderer.RenderBlockAsItem(Block.Tnt, 0, par1EntityTNTPrimed.GetBrightness(par9));

            if ((par1EntityTNTPrimed.Fuse / 5) % 2 == 0)
            {
                //GL.Disable(EnableCap.Texture2D);
                //GL.Disable(EnableCap.Lighting);
                //GL.Enable(EnableCap.Blend);
                //GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.DstAlpha);
                //GL.Color4(1.0F, 1.0F, 1.0F, f1);
                BlockRenderer.RenderBlockAsItem(Block.Tnt, 0, 1.0F);
                //GL.Color4(1.0F, 1.0F, 1.0F, 1.0F);
                //GL.Disable(EnableCap.Blend);
                //GL.Enable(EnableCap.Lighting);
                //GL.Enable(EnableCap.Texture2D);
            }

            //GL.PopMatrix();
        }
        /// <summary>
        /// Called right before the block is destroyed by a player.  Args: world, x, y, z, metaData
        /// </summary>
        public override void OnBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5)
        {
            if (par1World.IsRemote)
            {
                return;
            }

            if ((par5 & 1) == 0)
            {
                DropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(Block.Tnt.BlockID, 1, 0));
            }
            else
            {
                EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(par1World, (float)par2 + 0.5F, (float)par3 + 0.5F, (float)par4 + 0.5F);
                par1World.SpawnEntityInWorld(entitytntprimed);
                par1World.PlaySoundAtEntity(entitytntprimed, "random.fuse", 1.0F, 1.0F);
            }
        }
        public override void HandleVehicleSpawn(Packet23VehicleSpawn par1Packet23VehicleSpawn)
        {
            float  d   = par1Packet23VehicleSpawn.XPosition / 3F;
            float  d1  = par1Packet23VehicleSpawn.YPosition / 3F;
            float  d2  = par1Packet23VehicleSpawn.ZPosition / 3F;
            Entity obj = null;

            if (par1Packet23VehicleSpawn.Type == 10)
            {
                obj = new EntityMinecart(WorldClient, d, d1, d2, 0);
            }
            else if (par1Packet23VehicleSpawn.Type == 11)
            {
                obj = new EntityMinecart(WorldClient, d, d1, d2, 1);
            }
            else if (par1Packet23VehicleSpawn.Type == 12)
            {
                obj = new EntityMinecart(WorldClient, d, d1, d2, 2);
            }
            else if (par1Packet23VehicleSpawn.Type == 90)
            {
                obj = new EntityFishHook(WorldClient, d, d1, d2);
            }
            else if (par1Packet23VehicleSpawn.Type == 60)
            {
                obj = new EntityArrow(WorldClient, d, d1, d2);
            }
            else if (par1Packet23VehicleSpawn.Type == 61)
            {
                obj = new EntitySnowball(WorldClient, d, d1, d2);
            }
            else if (par1Packet23VehicleSpawn.Type == 65)
            {
                obj = new EntityEnderPearl(WorldClient, d, d1, d2);
            }
            else if (par1Packet23VehicleSpawn.Type == 72)
            {
                obj = new EntityEnderEye(WorldClient, d, d1, d2);
            }
            else if (par1Packet23VehicleSpawn.Type == 63)
            {
                obj = new EntityFireball(WorldClient, d, d1, d2, par1Packet23VehicleSpawn.SpeedX / 8000F, par1Packet23VehicleSpawn.SpeedY / 8000F, par1Packet23VehicleSpawn.SpeedZ / 8000F);
                par1Packet23VehicleSpawn.ThrowerEntityId = 0;
            }
            else if (par1Packet23VehicleSpawn.Type == 64)
            {
                obj = new EntitySmallFireball(WorldClient, d, d1, d2, par1Packet23VehicleSpawn.SpeedX / 8000F, par1Packet23VehicleSpawn.SpeedY / 8000F, par1Packet23VehicleSpawn.SpeedZ / 8000F);
                par1Packet23VehicleSpawn.ThrowerEntityId = 0;
            }
            else if (par1Packet23VehicleSpawn.Type == 62)
            {
                obj = new EntityEgg(WorldClient, d, d1, d2);
            }
            else if (par1Packet23VehicleSpawn.Type == 73)
            {
                obj = new EntityPotion(WorldClient, d, d1, d2, par1Packet23VehicleSpawn.ThrowerEntityId);
                par1Packet23VehicleSpawn.ThrowerEntityId = 0;
            }
            else if (par1Packet23VehicleSpawn.Type == 75)
            {
                obj = new EntityExpBottle(WorldClient, d, d1, d2);
                par1Packet23VehicleSpawn.ThrowerEntityId = 0;
            }
            else if (par1Packet23VehicleSpawn.Type == 1)
            {
                obj = new EntityBoat(WorldClient, d, d1, d2);
            }
            else if (par1Packet23VehicleSpawn.Type == 50)
            {
                obj = new EntityTNTPrimed(WorldClient, d, d1, d2);
            }
            else if (par1Packet23VehicleSpawn.Type == 51)
            {
                obj = new EntityEnderCrystal(WorldClient, d, d1, d2);
            }
            else if (par1Packet23VehicleSpawn.Type == 70)
            {
                obj = new EntityFallingSand(WorldClient, d, d1, d2, Block.Sand.BlockID);
            }
            else if (par1Packet23VehicleSpawn.Type == 71)
            {
                obj = new EntityFallingSand(WorldClient, d, d1, d2, Block.Gravel.BlockID);
            }
            else if (par1Packet23VehicleSpawn.Type == 74)
            {
                obj = new EntityFallingSand(WorldClient, d, d1, d2, Block.DragonEgg.BlockID);
            }

            if (obj != null)
            {
                obj.ServerPosX    = par1Packet23VehicleSpawn.XPosition;
                obj.ServerPosY    = par1Packet23VehicleSpawn.YPosition;
                obj.ServerPosZ    = par1Packet23VehicleSpawn.ZPosition;
                obj.RotationYaw   = 0.0F;
                obj.RotationPitch = 0.0F;
                Entity[] aentity = ((Entity)(obj)).GetParts();

                if (aentity != null)
                {
                    int i = par1Packet23VehicleSpawn.EntityId - ((Entity)(obj)).EntityId;

                    for (int j = 0; j < aentity.Length; j++)
                    {
                        aentity[j].EntityId += i;
                    }
                }

                obj.EntityId = par1Packet23VehicleSpawn.EntityId;
                WorldClient.AddEntityToWorld(par1Packet23VehicleSpawn.EntityId, ((Entity)(obj)));

                if (par1Packet23VehicleSpawn.ThrowerEntityId > 0)
                {
                    if (par1Packet23VehicleSpawn.Type == 60)
                    {
                        Entity entity = GetEntityByID(par1Packet23VehicleSpawn.ThrowerEntityId);

                        if (entity is EntityLiving)
                        {
                            ((EntityArrow)obj).ShootingEntity = (EntityLiving)entity;
                        }
                    }

                    ((Entity)(obj)).SetVelocity(par1Packet23VehicleSpawn.SpeedX / 8000F, par1Packet23VehicleSpawn.SpeedY / 8000F, par1Packet23VehicleSpawn.SpeedZ / 8000F);
                }
            }
        }