예제 #1
0
 /// <summary>
 /// Called when a lightning bolt hits the entity.
 /// </summary>
 public override void OnStruckByLightning(EntityLightningBolt par1EntityLightningBolt)
 {
     if (WorldObj.IsRemote)
     {
         return;
     }
     else
     {
         EntityPigZombie entitypigzombie = new EntityPigZombie(WorldObj);
         entitypigzombie.SetLocationAndAngles(PosX, PosY, PosZ, RotationYaw, RotationPitch);
         WorldObj.SpawnEntityInWorld(entitypigzombie);
         SetDead();
         return;
     }
 }
        /// <summary>
        /// Handles weather packet
        /// </summary>
        public override void HandleWeather(Packet71Weather par1Packet71Weather)
        {
            float d  = par1Packet71Weather.PosX / 32F;
            float d1 = par1Packet71Weather.PosY / 32F;
            float d2 = par1Packet71Weather.PosZ / 32F;
            EntityLightningBolt entitylightningbolt = null;

            if (par1Packet71Weather.IsLightningBolt == 1)
            {
                entitylightningbolt = new EntityLightningBolt(WorldClient, d, d1, d2);
            }

            if (entitylightningbolt != null)
            {
                entitylightningbolt.ServerPosX    = par1Packet71Weather.PosX;
                entitylightningbolt.ServerPosY    = par1Packet71Weather.PosY;
                entitylightningbolt.ServerPosZ    = par1Packet71Weather.PosZ;
                entitylightningbolt.RotationYaw   = 0.0F;
                entitylightningbolt.RotationPitch = 0.0F;
                entitylightningbolt.EntityId      = par1Packet71Weather.EntityID;
                WorldClient.AddWeatherEffect(entitylightningbolt);
            }
        }
예제 #3
0
        /// <summary>
        /// Actually renders the lightning bolt. This method is called through the doRender method.
        /// </summary>
        public virtual void DoRenderLightningBolt(EntityLightningBolt par1EntityLightningBolt, double par2, double par4, double par6, float par8, float par9)
        {
            Tessellator tessellator = Tessellator.Instance;

            //GL.Disable(EnableCap.Texture2D);
            //GL.Disable(EnableCap.Lighting);
            //GL.Enable(EnableCap.Blend);
            //GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One);
            double[] ad     = new double[8];
            double[] ad1    = new double[8];
            double   d      = 0.0F;
            double   d1     = 0.0F;
            Random   random = new Random((int)par1EntityLightningBolt.BoltVertex);

            for (int j = 7; j >= 0; j--)
            {
                ad[j]  = d;
                ad1[j] = d1;
                d     += random.Next(11) - 5;
                d1    += random.Next(11) - 5;
            }

            for (int i = 0; i < 4; i++)
            {
                Random random1 = new Random((int)par1EntityLightningBolt.BoltVertex);

                for (int k = 0; k < 3; k++)
                {
                    int l  = 7;
                    int i1 = 0;

                    if (k > 0)
                    {
                        l = 7 - k;
                    }

                    if (k > 0)
                    {
                        i1 = l - 2;
                    }

                    double d2 = ad[l] - d;
                    double d3 = ad1[l] - d1;

                    for (int j1 = l; j1 >= i1; j1--)
                    {
                        double d4 = d2;
                        double d5 = d3;

                        if (k == 0)
                        {
                            d2 += random1.Next(11) - 5;
                            d3 += random1.Next(11) - 5;
                        }
                        else
                        {
                            d2 += random1.Next(31) - 15;
                            d3 += random1.Next(31) - 15;
                        }

                        tessellator.StartDrawing(5);
                        float f = 0.5F;
                        tessellator.SetColorRGBA_F(0.9F * f, 0.9F * f, 1.0F * f, 0.3F);
                        double d6 = 0.10000000000000001D + (double)i * 0.20000000000000001D;

                        if (k == 0)
                        {
                            d6 *= (double)j1 * 0.10000000000000001D + 1.0D;
                        }

                        double d7 = 0.10000000000000001D + (double)i * 0.20000000000000001D;

                        if (k == 0)
                        {
                            d7 *= (double)(j1 - 1) * 0.10000000000000001D + 1.0D;
                        }

                        for (int k1 = 0; k1 < 5; k1++)
                        {
                            double d8 = (par2 + 0.5D) - d6;
                            double d9 = (par6 + 0.5D) - d6;

                            if (k1 == 1 || k1 == 2)
                            {
                                d8 += d6 * 2D;
                            }

                            if (k1 == 2 || k1 == 3)
                            {
                                d9 += d6 * 2D;
                            }

                            double d10 = (par2 + 0.5D) - d7;
                            double d11 = (par6 + 0.5D) - d7;

                            if (k1 == 1 || k1 == 2)
                            {
                                d10 += d7 * 2D;
                            }

                            if (k1 == 2 || k1 == 3)
                            {
                                d11 += d7 * 2D;
                            }

                            tessellator.AddVertex(d10 + d2, par4 + (double)(j1 * 16), d11 + d3);
                            tessellator.AddVertex(d8 + d4, par4 + (double)((j1 + 1) * 16), d9 + d5);
                        }

                        tessellator.Draw();
                    }
                }
            }

            //GL.Disable(EnableCap.Blend);
            //GL.Enable(EnableCap.Lighting);
            //GL.Enable(EnableCap.Texture2D);
        }
 /// <summary>
 /// Called when a lightning bolt hits the entity.
 /// </summary>
 public override void OnStruckByLightning(EntityLightningBolt par1EntityLightningBolt)
 {
     base.OnStruckByLightning(par1EntityLightningBolt);
     DataWatcher.UpdateObject(17, Convert.ToByte((sbyte)1));
 }