예제 #1
0
        /// <summary>
        /// Checks to see if this enderman should be attacking this player
        /// </summary>
        private bool ShouldAttackPlayer(EntityPlayer par1EntityPlayer)
        {
            ItemStack itemstack = par1EntityPlayer.Inventory.ArmorInventory[3];

            if (itemstack != null && itemstack.ItemID == Block.Pumpkin.BlockID)
            {
                return(false);
            }

            Vec3D  vec3d  = par1EntityPlayer.GetLook(1.0F).Normalize();
            Vec3D  vec3d1 = Vec3D.CreateVector(PosX - par1EntityPlayer.PosX, (BoundingBox.MinY + (double)(Height / 2.0F)) - (par1EntityPlayer.PosY + (double)par1EntityPlayer.GetEyeHeight()), PosZ - par1EntityPlayer.PosZ);
            double d      = vec3d1.LengthVector();

            vec3d1 = vec3d1.Normalize();
            double d1 = vec3d.DotProduct(vec3d1);

            if (d1 > 1.0D - 0.025000000000000001D / d)
            {
                return(par1EntityPlayer.CanEntityBeSeen(this));
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
        /// use this to react to sunlight and start to burn.
        /// </summary>
        public override void OnLivingUpdate()
        {
            Field_40173_aw = Field_40172_ax;

            if (!WorldObj.IsRemote)
            {
                DataWatcher.UpdateObject(16, Convert.ToInt32(Health));
            }

            if (Health <= 0)
            {
                float f  = (Rand.NextFloat() - 0.5F) * 8F;
                float f2 = (Rand.NextFloat() - 0.5F) * 4F;
                float f4 = (Rand.NextFloat() - 0.5F) * 8F;
                WorldObj.SpawnParticle("largeexplode", PosX + (double)f, PosY + 2D + (double)f2, PosZ + (double)f4, 0.0F, 0.0F, 0.0F);
                return;
            }

            UpdateDragonEnderCrystal();
            float f1 = 0.2F / (MathHelper2.Sqrt_double(MotionX * MotionX + MotionZ * MotionZ) * 10F + 1.0F);

            f1 *= (float)Math.Pow(2D, MotionY);

            if (Field_40161_az)
            {
                Field_40172_ax += f1 * 0.5F;
            }
            else
            {
                Field_40172_ax += f1;
            }

            for (; RotationYaw >= 180F; RotationYaw -= 360F)
            {
            }

            for (; RotationYaw < -180F; RotationYaw += 360F)
            {
            }

            if (Field_40164_e < 0)
            {
                for (int i = 0; i < Field_40162_d.Length; i++)
                {
                    Field_40162_d[i][0] = RotationYaw;
                    Field_40162_d[i][1] = PosY;
                }
            }

            if (++Field_40164_e == Field_40162_d.Length)
            {
                Field_40164_e = 0;
            }

            Field_40162_d[Field_40164_e][0] = RotationYaw;
            Field_40162_d[Field_40164_e][1] = PosY;

            if (WorldObj.IsRemote)
            {
                if (NewPosRotationIncrements > 0)
                {
                    float  d  = PosX + (NewPosX - PosX) / NewPosRotationIncrements;
                    float  d2 = PosY + (NewPosY - PosY) / NewPosRotationIncrements;
                    float  d4 = PosZ + (NewPosZ - PosZ) / NewPosRotationIncrements;
                    double d6;

                    for (d6 = NewRotationYaw - (double)RotationYaw; d6 < -180D; d6 += 360D)
                    {
                    }

                    for (; d6 >= 180D; d6 -= 360D)
                    {
                    }

                    RotationYaw   += (float)d6 / NewPosRotationIncrements;
                    RotationPitch += (float)(NewRotationPitch - RotationPitch) / NewPosRotationIncrements;
                    NewPosRotationIncrements--;
                    SetPosition(d, d2, d4);
                    SetRotation(RotationYaw, RotationPitch);
                }
            }
            else
            {
                double d1 = TargetX - PosX;
                float  d3 = TargetY - PosY;
                double d5 = TargetZ - PosZ;
                double d7 = d1 * d1 + d3 * d3 + d5 * d5;

                if (Target != null)
                {
                    TargetX = Target.PosX;
                    TargetZ = Target.PosZ;
                    float d8  = TargetX - PosX;
                    float d10 = TargetZ - PosZ;
                    float d12 = (float)Math.Sqrt(d8 * d8 + d10 * d10);
                    float d13 = (0.40000000596046448F + d12 / 80F) - 1.0F;

                    if (d13 > 10F)
                    {
                        d13 = 10F;
                    }

                    TargetY = Target.BoundingBox.MinY + d13;
                }
                else
                {
                    TargetX += Rand.NextGaussian() * 2F;
                    TargetZ += Rand.NextGaussian() * 2F;
                }

                if (Field_40163_ay || d7 < 100D || d7 > 22500D || IsCollidedHorizontally || IsCollidedVertically)
                {
                    Func_41006_aA();
                }

                d3 /= MathHelper2.Sqrt_double(d1 * d1 + d5 * d5);
                float f10 = 0.6F;

                if (d3 < (double)(-f10))
                {
                    d3 = -f10;
                }

                if (d3 > (double)f10)
                {
                    d3 = f10;
                }

                MotionY += d3 * 0.10000000149011612F;

                for (; RotationYaw < -180F; RotationYaw += 360F)
                {
                }

                for (; RotationYaw >= 180F; RotationYaw -= 360F)
                {
                }

                double d9 = 180D - (Math.Atan2(d1, d5) * 180D) / Math.PI;
                double d11;

                for (d11 = d9 - (double)RotationYaw; d11 < -180D; d11 += 360D)
                {
                }

                for (; d11 >= 180D; d11 -= 360D)
                {
                }

                if (d11 > 50D)
                {
                    d11 = 50D;
                }

                if (d11 < -50D)
                {
                    d11 = -50D;
                }

                Vec3D vec3d  = Vec3D.CreateVector(TargetX - PosX, TargetY - PosY, TargetZ - PosZ).Normalize();
                Vec3D vec3d1 = Vec3D.CreateVector(MathHelper2.Sin((RotationYaw * (float)Math.PI) / 180F), MotionY, -MathHelper2.Cos((RotationYaw * (float)Math.PI) / 180F)).Normalize();
                float f18    = (float)(vec3d1.DotProduct(vec3d) + 0.5D) / 1.5F;

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

                RandomYawVelocity *= 0.8F;
                float  f19 = MathHelper2.Sqrt_double(MotionX * MotionX + MotionZ * MotionZ) * 1.0F + 1.0F;
                double d14 = Math.Sqrt(MotionX * MotionX + MotionZ * MotionZ) * 1.0D + 1.0D;

                if (d14 > 40D)
                {
                    d14 = 40D;
                }

                RandomYawVelocity += (float)(d11 * (0.69999998807907104D / d14 / f19));
                RotationYaw       += RandomYawVelocity * 0.1F;
                float f20 = (float)(2D / (d14 + 1.0D));
                float f21 = 0.06F;
                MoveFlying(0.0F, -1F, f21 * (f18 * f20 + (1.0F - f20)));

                if (Field_40161_az)
                {
                    MoveEntity(MotionX * 0.80000001192092896F, MotionY * 0.80000001192092896F, MotionZ * 0.80000001192092896F);
                }
                else
                {
                    MoveEntity(MotionX, MotionY, MotionZ);
                }

                Vec3D vec3d2 = Vec3D.CreateVector(MotionX, MotionY, MotionZ).Normalize();
                float f22    = (float)(vec3d2.DotProduct(vec3d1) + 1.0D) / 2.0F;
                f22      = 0.8F + 0.15F * f22;
                MotionX *= f22;
                MotionZ *= f22;
                MotionY *= 0.9100000262260437F;
            }

            RenderYawOffset        = RotationYaw;
            DragonPartHead.Width   = DragonPartHead.Height = 3F;
            DragonPartTail1.Width  = DragonPartTail1.Height = 2.0F;
            DragonPartTail2.Width  = DragonPartTail2.Height = 2.0F;
            DragonPartTail3.Width  = DragonPartTail3.Height = 2.0F;
            DragonPartBody.Height  = 3F;
            DragonPartBody.Width   = 5F;
            DragonPartWing1.Height = 2.0F;
            DragonPartWing1.Width  = 4F;
            DragonPartWing2.Height = 3F;
            DragonPartWing2.Width  = 4F;
            float f3 = (((float)(Func_40160_a(5, 1.0F)[1] - Func_40160_a(10, 1.0F)[1]) * 10F) / 180F) * (float)Math.PI;
            float f5 = MathHelper2.Cos(f3);
            float f6 = -MathHelper2.Sin(f3);
            float f7 = (RotationYaw * (float)Math.PI) / 180F;
            float f8 = MathHelper2.Sin(f7);
            float f9 = MathHelper2.Cos(f7);

            DragonPartBody.OnUpdate();
            DragonPartBody.SetLocationAndAngles(PosX + (f8 * 0.5F), PosY, PosZ - (f9 * 0.5F), 0.0F, 0.0F);
            DragonPartWing1.OnUpdate();
            DragonPartWing1.SetLocationAndAngles(PosX + (f9 * 4.5F), PosY + 2F, PosZ + (f8 * 4.5F), 0.0F, 0.0F);
            DragonPartWing2.OnUpdate();
            DragonPartWing2.SetLocationAndAngles(PosX - (f9 * 4.5F), PosY + 2F, PosZ - (f8 * 4.5F), 0.0F, 0.0F);

            if (!WorldObj.IsRemote)
            {
                Func_41007_az();
            }

            if (!WorldObj.IsRemote && MaxHurtTime == 0)
            {
                CollideWithEntities(WorldObj.GetEntitiesWithinAABBExcludingEntity(this, DragonPartWing1.BoundingBox.Expand(4, 2, 4).Offset(0.0F, -2F, 0.0F)));
                CollideWithEntities(WorldObj.GetEntitiesWithinAABBExcludingEntity(this, DragonPartWing2.BoundingBox.Expand(4, 2, 4).Offset(0.0F, -2F, 0.0F)));
                AttackEntitiesInList(WorldObj.GetEntitiesWithinAABBExcludingEntity(this, DragonPartHead.BoundingBox.Expand(1.0F, 1.0F, 1.0F)));
            }

            float[] ad  = Func_40160_a(5, 1.0F);
            float[] ad1 = Func_40160_a(0, 1.0F);
            float   f11 = MathHelper2.Sin((RotationYaw * (float)Math.PI) / 180F - RandomYawVelocity * 0.01F);
            float   f12 = MathHelper2.Cos((RotationYaw * (float)Math.PI) / 180F - RandomYawVelocity * 0.01F);

            DragonPartHead.OnUpdate();
            DragonPartHead.SetLocationAndAngles(PosX + (f11 * 5.5F * f5), PosY + (ad1[1] - ad[1]) * 1.0F + (f6 * 5.5F), PosZ - (f12 * 5.5F * f5), 0.0F, 0.0F);

            for (int j = 0; j < 3; j++)
            {
                EntityDragonPart entitydragonpart = null;

                if (j == 0)
                {
                    entitydragonpart = DragonPartTail1;
                }

                if (j == 1)
                {
                    entitydragonpart = DragonPartTail2;
                }

                if (j == 2)
                {
                    entitydragonpart = DragonPartTail3;
                }

                float[] ad2 = Func_40160_a(12 + j * 2, 1.0F);
                float   f13 = (RotationYaw * (float)Math.PI) / 180F + ((SimplifyAngle(ad2[0] - ad[0]) * (float)Math.PI) / 180F) * 1.0F;
                float   f14 = MathHelper2.Sin(f13);
                float   f15 = MathHelper2.Cos(f13);
                float   f16 = 1.5F;
                float   f17 = (float)(j + 1) * 2.0F;
                entitydragonpart.OnUpdate();
                entitydragonpart.SetLocationAndAngles(PosX - ((f8 * f16 + f14 * f17) * f5), ((PosY + (ad2[1] - ad[1]) * 1.0F) - ((f17 + f16) * f6)) + 1.5F, PosZ + ((f9 * f16 + f15 * f17) * f5), 0.0F, 0.0F);
            }

            if (!WorldObj.IsRemote)
            {
                Field_40161_az = DestroyBlocksInAABB(DragonPartHead.BoundingBox) | DestroyBlocksInAABB(DragonPartBody.BoundingBox);
            }
        }
예제 #3
0
        /// <summary>
        /// Applies a velocity to each of the entities pushing them away from each other. Args: entity
        /// </summary>
        public override void ApplyEntityCollision(Entity par1Entity)
        {
            if (WorldObj.IsRemote)
            {
                return;
            }

            if (par1Entity == RiddenByEntity)
            {
                return;
            }

            if ((par1Entity is EntityLiving) && !(par1Entity is EntityPlayer) && !(par1Entity is EntityIronGolem) && MinecartType == 0 && MotionX * MotionX + MotionZ * MotionZ > 0.01D && RiddenByEntity == null && par1Entity.RidingEntity == null)
            {
                par1Entity.MountEntity(this);
            }

            float d  = par1Entity.PosX - PosX;
            float d1 = par1Entity.PosZ - PosZ;
            float d2 = d * d + d1 * d1;

            //JAVA TO C# CONVERTER TODO TASK: Octal literals cannot be represented in C#:
            if (d2 >= 9.9999997473787516E-005D)
            {
                d2  = MathHelper2.Sqrt_double(d2);
                d  /= d2;
                d1 /= d2;
                float d3 = 1.0F / d2;

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

                d  *= d3;
                d1 *= d3;
                d  *= 0.10000000149011612F;
                d1 *= 0.10000000149011612F;
                d  *= 1.0F - EntityCollisionReduction;
                d1 *= 1.0F - EntityCollisionReduction;
                d  *= 0.5F;
                d1 *= 0.5F;

                if (par1Entity is EntityMinecart)
                {
                    double d4     = par1Entity.PosX - PosX;
                    double d5     = par1Entity.PosZ - PosZ;
                    Vec3D  vec3d  = Vec3D.CreateVector(d4, 0.0F, d5).Normalize();
                    Vec3D  vec3d1 = Vec3D.CreateVector(MathHelper2.Cos((RotationYaw * (float)Math.PI) / 180F), 0.0F, MathHelper2.Sin((RotationYaw * (float)Math.PI) / 180F)).Normalize();
                    double d6     = Math.Abs(vec3d.DotProduct(vec3d1));

                    if (d6 < 0.80000001192092896D)
                    {
                        return;
                    }

                    float d7 = par1Entity.MotionX + MotionX;
                    float d8 = par1Entity.MotionZ + MotionZ;

                    if (((EntityMinecart)par1Entity).MinecartType == 2 && MinecartType != 2)
                    {
                        MotionX *= 0.20000000298023224F;
                        MotionZ *= 0.20000000298023224F;
                        AddVelocity(par1Entity.MotionX - d, 0.0F, par1Entity.MotionZ - d1);
                        par1Entity.MotionX *= 0.94999998807907104F;
                        par1Entity.MotionZ *= 0.94999998807907104F;
                    }
                    else if (((EntityMinecart)par1Entity).MinecartType != 2 && MinecartType == 2)
                    {
                        par1Entity.MotionX *= 0.20000000298023224F;
                        par1Entity.MotionZ *= 0.20000000298023224F;
                        par1Entity.AddVelocity(MotionX + d, 0.0F, MotionZ + d1);
                        MotionX *= 0.94999998807907104F;
                        MotionZ *= 0.94999998807907104F;
                    }
                    else
                    {
                        d7      /= 2F;
                        d8      /= 2F;
                        MotionX *= 0.20000000298023224F;
                        MotionZ *= 0.20000000298023224F;
                        AddVelocity(d7 - d, 0.0F, d8 - d1);
                        par1Entity.MotionX *= 0.20000000298023224F;
                        par1Entity.MotionZ *= 0.20000000298023224F;
                        par1Entity.AddVelocity(d7 + d, 0.0F, d8 + d1);
                    }
                }
                else
                {
                    AddVelocity(-d, 0.0F, -d1);
                    par1Entity.AddVelocity(d / 4F, 0.0F, d1 / 4F);
                }
            }
        }