Пример #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>
        /// Returns whether the EntityAIBase should begin execution.
        /// </summary>
        public override bool ShouldExecute()
        {
            if (TargetEntityClass == (typeof(net.minecraft.src.EntityPlayer)))
            {
                if ((TheEntity is EntityTameable) && ((EntityTameable)TheEntity).IsTamed())
                {
                    return(false);
                }

                Field_48240_d = TheEntity.WorldObj.GetClosestPlayerToEntity(TheEntity, Field_48241_e);

                if (Field_48240_d == null)
                {
                    return(false);
                }
            }
            else
            {
                List <Entity> list = TheEntity.WorldObj.GetEntitiesWithinAABB(TargetEntityClass, TheEntity.BoundingBox.Expand(Field_48241_e, 3, Field_48241_e));

                if (list.Count == 0)
                {
                    return(false);
                }

                Field_48240_d = list[0];
            }

            if (!TheEntity.Func_48090_aM().CanSee(Field_48240_d))
            {
                return(false);
            }

            Vec3D vec3d = RandomPositionGenerator.Func_48623_b(TheEntity, 16, 7, Vec3D.CreateVector(Field_48240_d.PosX, Field_48240_d.PosY, Field_48240_d.PosZ));

            if (vec3d == null)
            {
                return(false);
            }

            if (Field_48240_d.GetDistanceSq((float)vec3d.XCoord, (float)vec3d.YCoord, (float)vec3d.ZCoord) < Field_48240_d.GetDistanceSqToEntity(TheEntity))
            {
                return(false);
            }

            Field_48238_f = EntityPathNavigate.GetPathToXYZ(vec3d.XCoord, vec3d.YCoord, vec3d.ZCoord);

            if (Field_48238_f == null)
            {
                return(false);
            }

            return(Field_48238_f.Func_48639_a(vec3d));
        }
Пример #3
0
        /// <summary>
        /// Returns a vector representing the projection along the given entity's view for the given distance
        /// </summary>
        public static Vec3D ProjectViewFromEntity(EntityLiving par0EntityLiving, double par1)
        {
            double d  = par0EntityLiving.PrevPosX + (par0EntityLiving.PosX - par0EntityLiving.PrevPosX) * par1;
            double d1 = par0EntityLiving.PrevPosY + (par0EntityLiving.PosY - par0EntityLiving.PrevPosY) * par1 + (double)par0EntityLiving.GetEyeHeight();
            double d2 = par0EntityLiving.PrevPosZ + (par0EntityLiving.PosZ - par0EntityLiving.PrevPosZ) * par1;
            double d3 = d + (double)(ObjectX * 1.0F);
            double d4 = d1 + (double)(ObjectY * 1.0F);
            double d5 = d2 + (double)(ObjectZ * 1.0F);

            return(Vec3D.CreateVector(d3, d4, d5));
        }
Пример #4
0
        /// <summary>
        /// Teleport the enderman to another entity
        /// </summary>
        protected virtual bool TeleportToEntity(Entity par1Entity)
        {
            Vec3D vec3d = Vec3D.CreateVector(PosX - par1Entity.PosX, ((BoundingBox.MinY + (double)(Height / 2.0F)) - par1Entity.PosY) + (double)par1Entity.GetEyeHeight(), PosZ - par1Entity.PosZ);

            vec3d = vec3d.Normalize();
            float d  = 16;
            float d1 = (PosX + (Rand.NextFloat() - 0.5F) * 8) - (float)vec3d.XCoord * d;
            float d2 = (PosY + (Rand.Next(16) - 8)) - (float)vec3d.YCoord * d;
            float d3 = (PosZ + (Rand.NextFloat() - 0.5F) * 8) - (float)vec3d.ZCoord * d;

            return(TeleportTo(d1, d2, d3));
        }
        /// <summary>
        /// Returns whether the EntityAIBase should begin execution.
        /// </summary>
        public override bool ShouldExecute()
        {
            Func_48286_h();

            if (Field_48289_e && TheEntity.WorldObj.IsDaytime())
            {
                return(false);
            }

            Village village = TheEntity.WorldObj.VillageCollectionObj.FindNearestVillage(MathHelper2.Floor_double(TheEntity.PosX), MathHelper2.Floor_double(TheEntity.PosY), MathHelper2.Floor_double(TheEntity.PosZ), 0);

            if (village == null)
            {
                return(false);
            }

            DoorInfo = Func_48284_a(village);

            if (DoorInfo == null)
            {
                return(false);
            }

            bool flag = TheEntity.GetNavigator().Func_48665_b();

            TheEntity.GetNavigator().SetBreakDoors(false);
            Field_48291_c = TheEntity.GetNavigator().GetPathToXYZ(DoorInfo.PosX, DoorInfo.PosY, DoorInfo.PosZ);
            TheEntity.GetNavigator().SetBreakDoors(flag);

            if (Field_48291_c != null)
            {
                return(true);
            }

            Vec3D vec3d = RandomPositionGenerator.Func_48620_a(TheEntity, 10, 7, Vec3D.CreateVector(DoorInfo.PosX, DoorInfo.PosY, DoorInfo.PosZ));

            if (vec3d == null)
            {
                return(false);
            }
            else
            {
                TheEntity.GetNavigator().SetBreakDoors(false);
                Field_48291_c = TheEntity.GetNavigator().GetPathToXYZ(vec3d.XCoord, vec3d.YCoord, vec3d.ZCoord);
                TheEntity.GetNavigator().SetBreakDoors(flag);
                return(Field_48291_c != null);
            }
        }
Пример #6
0
        private Vec3D Func_48572_a(int par1, int par2, int par3)
        {
            for (int i = 0; i < 10; i++)
            {
                int j = (par1 + Field_48582_a.Rand.Next(16)) - 8;
                int k = (par2 + Field_48582_a.Rand.Next(6)) - 3;
                int l = (par3 + Field_48582_a.Rand.Next(16)) - 8;

                if (Field_48576_f.IsInRange(j, k, l) && SpawnerAnimals.CanCreatureTypeSpawnAtLocation(CreatureType.Monster, Field_48582_a, j, k, l))
                {
                    return(Vec3D.CreateVector(j, k, l));
                }
            }

            return(null);
        }
Пример #7
0
        /// <summary>
        /// Tries up to 10 times to get a valid spawning location before eventually failing and returning null.
        /// </summary>
        private Vec3D TryGetIronGolemSpawningLocation(int par1, int par2, int par3, int par4, int par5, int par6)
        {
            for (int i = 0; i < 10; i++)
            {
                int j = (par1 + WorldObj.Rand.Next(16)) - 8;
                int k = (par2 + WorldObj.Rand.Next(6)) - 3;
                int l = (par3 + WorldObj.Rand.Next(16)) - 8;

                if (IsInRange(j, k, l) && IsValidIronGolemSpawningLocation(j, k, l, par4, par5, par6))
                {
                    return(Vec3D.CreateVector(j, k, l));
                }
            }

            return(null);
        }
Пример #8
0
        private Vec3D FindPossibleShelter()
        {
            Random random = TheCreature.GetRNG();

            for (int i = 0; i < 10; i++)
            {
                int j = MathHelper2.Floor_double((TheCreature.PosX + (double)random.Next(20)) - 10D);
                int k = MathHelper2.Floor_double((TheCreature.BoundingBox.MinY + (double)random.Next(6)) - 3D);
                int l = MathHelper2.Floor_double((TheCreature.PosZ + (double)random.Next(20)) - 10D);

                if (!TheWorld.CanBlockSeeTheSky(j, k, l) && TheCreature.GetBlockPathWeight(j, k, l) < 0.0F)
                {
                    return(Vec3D.CreateVector(j, k, l));
                }
            }

            return(null);
        }
Пример #9
0
        protected virtual MovingObjectPosition GetMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, bool par3)
        {
            float  f      = 1.0F;
            float  f1     = par2EntityPlayer.PrevRotationPitch + (par2EntityPlayer.RotationPitch - par2EntityPlayer.PrevRotationPitch) * f;
            float  f2     = par2EntityPlayer.PrevRotationYaw + (par2EntityPlayer.RotationYaw - par2EntityPlayer.PrevRotationYaw) * f;
            double d      = par2EntityPlayer.PrevPosX + (par2EntityPlayer.PosX - par2EntityPlayer.PrevPosX) * (double)f;
            double d1     = (par2EntityPlayer.PrevPosY + (par2EntityPlayer.PosY - par2EntityPlayer.PrevPosY) * (double)f + 1.6200000000000001D) - (double)par2EntityPlayer.YOffset;
            double d2     = par2EntityPlayer.PrevPosZ + (par2EntityPlayer.PosZ - par2EntityPlayer.PrevPosZ) * (double)f;
            Vec3D  vec3d  = Vec3D.CreateVector(d, d1, d2);
            float  f3     = MathHelper2.Cos(-f2 * 0.01745329F - (float)Math.PI);
            float  f4     = MathHelper2.Sin(-f2 * 0.01745329F - (float)Math.PI);
            float  f5     = -MathHelper2.Cos(-f1 * 0.01745329F);
            float  f6     = MathHelper2.Sin(-f1 * 0.01745329F);
            float  f7     = f4 * f5;
            float  f8     = f6;
            float  f9     = f3 * f5;
            double d3     = 5D;
            Vec3D  vec3d1 = vec3d.AddVector((double)f7 * d3, (double)f8 * d3, (double)f9 * d3);
            MovingObjectPosition movingobjectposition = par1World.RayTraceBlocks_do_do(vec3d, vec3d1, par3, !par3);

            return(movingobjectposition);
        }
Пример #10
0
        /// <summary>
        /// Return Vec3D with biome specific fog color
        /// </summary>
        public virtual Vec3D GetFogColor(float par1, float par2)
        {
            float f = MathHelper2.Cos(par1 * (float)Math.PI * 2.0F) * 2.0F + 0.5F;

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

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

            float f1 = 0.7529412F;
            float f2 = 0.8470588F;
            float f3 = 1.0F;

            f1 *= f * 0.94F + 0.06F;
            f2 *= f * 0.94F + 0.06F;
            f3 *= f * 0.91F + 0.09F;
            return(Vec3D.CreateVector(f1, f2, f3));
        }
Пример #11
0
        /// <summary>
        /// Sets the OpenGL lighting properties to the values used when rendering blocks as items
        /// </summary>
        public static void EnableStandardItemLighting()
        {        /*
                  *     //GL.Enable(EnableCap.Lighting);
                  *     //GL.Enable(EnableCap.Light0);
                  *     //GL.Enable(EnableCap.Light1);
                  *     //GL.Enable(EnableCap.ColorMaterial);
                  *     //GL.ColorMaterial(MaterialFace.FrontAndBack, ColorMaterialParameter.AmbientAndDiffuse);*/
            float f     = 0.4F;
            float f1    = 0.6F;
            float f2    = 0.0F;
            Vec3D vec3d = Vec3D.CreateVector(0.20000000298023224D, 1.0D, -0.69999998807907104D).Normalize();      /*
                                                                                                                   * //GL.Light(LightName.Light0, LightParameter.Position, GetColor(vec3d.XCoord, vec3d.YCoord, vec3d.ZCoord, 0.0F));
                                                                                                                   * //GL.Light(LightName.Light0, LightParameter.Diffuse, GetColor(f1, f1, f1, 1.0F));
                                                                                                                   * //GL.Light(LightName.Light0, LightParameter.Ambient, GetColor(0.0F, 0.0F, 0.0F, 1.0F));
                                                                                                                   * //GL.Light(LightName.Light0, LightParameter.Specular, GetColor(f2, f2, f2, 1.0F));*/

            vec3d = Vec3D.CreateVector(-0.20000000298023224D, 1.0D, 0.69999998807907104D).Normalize();            /*
                                                                                                                   * //GL.Light(LightName.Light1, LightParameter.Position, GetColor(vec3d.XCoord, vec3d.YCoord, vec3d.ZCoord, 0.0F));
                                                                                                                   * //GL.Light(LightName.Light1, LightParameter.Diffuse, GetColor(f1, f1, f1, 1.0F));
                                                                                                                   * //GL.Light(LightName.Light1, LightParameter.Ambient, GetColor(0.0F, 0.0F, 0.0F, 1.0F));
                                                                                                                   * //GL.Light(LightName.Light1, LightParameter.Specular, GetColor(f2, f2, f2, 1.0F));
                                                                                                                   * //GL.ShadeModel(ShadingModel.Flat);
                                                                                                                   * //GL.LightModel(LightModelParameter.LightModelAmbient, GetColor(f, f, f, 1.0F));*/
        }
        /// <summary>
        /// Return Vec3D with biome specific fog color
        /// </summary>
        public override Vec3D GetFogColor(float par1, float par2)
        {
            int   i = 0x8080a0;
            float f = MathHelper2.Cos(par1 * (float)Math.PI * 2.0F) * 2.0F + 0.5F;

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

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

            float f1 = (float)(i >> 16 & 0xff) / 255F;
            float f2 = (float)(i >> 8 & 0xff) / 255F;
            float f3 = (float)(i & 0xff) / 255F;

            f1 *= f * 0.0F + 0.15F;
            f2 *= f * 0.0F + 0.15F;
            f3 *= f * 0.0F + 0.15F;
            return(Vec3D.CreateVector(f1, f2, f3));
        }
Пример #13
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);
            }
        }
        /// <summary>
        /// Called to update the entity's position/logic.
        /// </summary>
        public override void OnUpdate()
        {
            LastTickPosX = PosX;
            LastTickPosY = PosY;
            LastTickPosZ = PosZ;
            base.OnUpdate();

            if (ThrowableShake > 0)
            {
                ThrowableShake--;
            }

            if (InGround)
            {
                int i = WorldObj.GetBlockId(XTile, YTile, ZTile);

                if (i != InTile)
                {
                    InGround      = false;
                    MotionX      *= Rand.NextFloat() * 0.2F;
                    MotionY      *= Rand.NextFloat() * 0.2F;
                    MotionZ      *= Rand.NextFloat() * 0.2F;
                    TicksInGround = 0;
                    TicksInAir    = 0;
                }
                else
                {
                    TicksInGround++;

                    if (TicksInGround == 1200)
                    {
                        SetDead();
                    }

                    return;
                }
            }
            else
            {
                TicksInAir++;
            }

            Vec3D vec3d  = Vec3D.CreateVector(PosX, PosY, PosZ);
            Vec3D vec3d1 = Vec3D.CreateVector(PosX + MotionX, PosY + MotionY, PosZ + MotionZ);
            MovingObjectPosition movingobjectposition = WorldObj.RayTraceBlocks(vec3d, vec3d1);

            vec3d  = Vec3D.CreateVector(PosX, PosY, PosZ);
            vec3d1 = Vec3D.CreateVector(PosX + MotionX, PosY + MotionY, PosZ + MotionZ);

            if (movingobjectposition != null)
            {
                vec3d1 = Vec3D.CreateVector(movingobjectposition.HitVec.XCoord, movingobjectposition.HitVec.YCoord, movingobjectposition.HitVec.ZCoord);
            }

            if (!WorldObj.IsRemote)
            {
                Entity        entity = null;
                List <Entity> list   = WorldObj.GetEntitiesWithinAABBExcludingEntity(this, BoundingBox.AddCoord(MotionX, MotionY, MotionZ).Expand(1.0F, 1.0F, 1.0F));
                float         d      = 0.0F;

                for (int k = 0; k < list.Count; k++)
                {
                    Entity entity1 = list[k];

                    if (!entity1.CanBeCollidedWith() || entity1 == Thrower && TicksInAir < 5)
                    {
                        continue;
                    }

                    float                f4                    = 0.3F;
                    AxisAlignedBB        axisalignedbb         = entity1.BoundingBox.Expand(f4, f4, f4);
                    MovingObjectPosition movingobjectposition1 = axisalignedbb.CalculateIntercept(vec3d, vec3d1);

                    if (movingobjectposition1 == null)
                    {
                        continue;
                    }

                    float d1 = (float)vec3d.DistanceTo(movingobjectposition1.HitVec);

                    if (d1 < d || d == 0.0F)
                    {
                        entity = entity1;
                        d      = d1;
                    }
                }

                if (entity != null)
                {
                    movingobjectposition = new MovingObjectPosition(entity);
                }
            }

            if (movingobjectposition != null)
            {
                OnImpact(movingobjectposition);
            }

            PosX += MotionX;
            PosY += MotionY;
            PosZ += MotionZ;
            float f = MathHelper2.Sqrt_double(MotionX * MotionX + MotionZ * MotionZ);

            RotationYaw = (float)((Math.Atan2(MotionX, MotionZ) * 180D) / Math.PI);

            for (RotationPitch = (float)((Math.Atan2(MotionY, f) * 180D) / Math.PI); RotationPitch - PrevRotationPitch < -180F; PrevRotationPitch -= 360F)
            {
            }

            for (; RotationPitch - PrevRotationPitch >= 180F; PrevRotationPitch += 360F)
            {
            }

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

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

            RotationPitch = PrevRotationPitch + (RotationPitch - PrevRotationPitch) * 0.2F;
            RotationYaw   = PrevRotationYaw + (RotationYaw - PrevRotationYaw) * 0.2F;
            float f1 = 0.99F;
            float f2 = Func_40075_e();

            if (IsInWater())
            {
                for (int j = 0; j < 4; j++)
                {
                    float f3 = 0.25F;
                    WorldObj.SpawnParticle("bubble", PosX - MotionX * f3, PosY - MotionY * f3, PosZ - MotionZ * f3, MotionX, MotionY, MotionZ);
                }

                f1 = 0.8F;
            }

            MotionX *= f1;
            MotionY *= f1;
            MotionZ *= f1;
            MotionY -= f2;
            SetPosition(PosX, PosY, PosZ);
        }
Пример #15
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);
                }
            }
        }
Пример #16
0
        public virtual Vec3D Func_514_g(double par1, double par3, double par5)
        {
            int i = MathHelper2.Floor_double(par1);
            int j = MathHelper2.Floor_double(par3);
            int k = MathHelper2.Floor_double(par5);

            if (BlockRail.IsRailBlockAt(WorldObj, i, j - 1, k))
            {
                j--;
            }

            int l = WorldObj.GetBlockId(i, j, k);

            if (BlockRail.IsRailBlock(l))
            {
                int i1 = WorldObj.GetBlockMetadata(i, j, k);
                par3 = j;

                if (((BlockRail)Block.BlocksList[l]).IsPowered())
                {
                    i1 &= 7;
                }

                if (i1 >= 2 && i1 <= 5)
                {
                    par3 = j + 1;
                }

                int[][] ai = Field_855_j[i1];
                double  d  = 0.0F;
                double  d1 = (double)i + 0.5D + (double)ai[0][0] * 0.5D;
                double  d2 = (double)j + 0.5D + (double)ai[0][1] * 0.5D;
                double  d3 = (double)k + 0.5D + (double)ai[0][2] * 0.5D;
                double  d4 = (double)i + 0.5D + (double)ai[1][0] * 0.5D;
                double  d5 = (double)j + 0.5D + (double)ai[1][1] * 0.5D;
                double  d6 = (double)k + 0.5D + (double)ai[1][2] * 0.5D;
                double  d7 = d4 - d1;
                double  d8 = (d5 - d2) * 2D;
                double  d9 = d6 - d3;

                if (d7 == 0.0F)
                {
                    par1 = (double)i + 0.5D;
                    d    = par5 - (double)k;
                }
                else if (d9 == 0.0F)
                {
                    par5 = (double)k + 0.5D;
                    d    = par1 - (double)i;
                }
                else
                {
                    double d10 = par1 - d1;
                    double d11 = par5 - d3;
                    double d12 = (d10 * d7 + d11 * d9) * 2D;
                    d = d12;
                }

                par1 = d1 + d7 * d;
                par3 = d2 + d8 * d;
                par5 = d3 + d9 * d;

                if (d8 < 0.0F)
                {
                    par3++;
                }

                if (d8 > 0.0F)
                {
                    par3 += 0.5D;
                }

                return(Vec3D.CreateVector(par1, par3, par5));
            }
            else
            {
                return(null);
            }
        }
Пример #17
0
        /// <summary>
        /// Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
        /// </summary>
        public override ItemStack OnItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
        {
            float  f      = 1.0F;
            float  f1     = par3EntityPlayer.PrevRotationPitch + (par3EntityPlayer.RotationPitch - par3EntityPlayer.PrevRotationPitch) * f;
            float  f2     = par3EntityPlayer.PrevRotationYaw + (par3EntityPlayer.RotationYaw - par3EntityPlayer.PrevRotationYaw) * f;
            double d      = par3EntityPlayer.PrevPosX + (par3EntityPlayer.PosX - par3EntityPlayer.PrevPosX) * (double)f;
            double d1     = (par3EntityPlayer.PrevPosY + (par3EntityPlayer.PosY - par3EntityPlayer.PrevPosY) * (double)f + 1.6200000000000001D) - (double)par3EntityPlayer.YOffset;
            double d2     = par3EntityPlayer.PrevPosZ + (par3EntityPlayer.PosZ - par3EntityPlayer.PrevPosZ) * (double)f;
            Vec3D  vec3d  = Vec3D.CreateVector(d, d1, d2);
            float  f3     = MathHelper2.Cos(-f2 * 0.01745329F - (float)Math.PI);
            float  f4     = MathHelper2.Sin(-f2 * 0.01745329F - (float)Math.PI);
            float  f5     = -MathHelper2.Cos(-f1 * 0.01745329F);
            float  f6     = MathHelper2.Sin(-f1 * 0.01745329F);
            float  f7     = f4 * f5;
            float  f8     = f6;
            float  f9     = f3 * f5;
            float  d3     = 5;
            Vec3D  vec3d1 = vec3d.AddVector((double)f7 * d3, (double)f8 * d3, (double)f9 * d3);
            MovingObjectPosition movingobjectposition = par2World.RayTraceBlocks_do(vec3d, vec3d1, true);

            if (movingobjectposition == null)
            {
                return(par1ItemStack);
            }

            Vec3D         vec3d2 = par3EntityPlayer.GetLook(f);
            bool          flag   = false;
            float         f10    = 1.0F;
            List <Entity> list   = par2World.GetEntitiesWithinAABBExcludingEntity(par3EntityPlayer, par3EntityPlayer.BoundingBox.AddCoord((float)vec3d2.XCoord * d3, (float)vec3d2.YCoord * d3, (float)vec3d2.ZCoord * d3).Expand(f10, f10, f10));

            for (int l = 0; l < list.Count; l++)
            {
                Entity entity = list[l];

                if (!entity.CanBeCollidedWith())
                {
                    continue;
                }

                float         f11           = entity.GetCollisionBorderSize();
                AxisAlignedBB axisalignedbb = entity.BoundingBox.Expand(f11, f11, f11);

                if (axisalignedbb.IsVecInside(vec3d))
                {
                    flag = true;
                }
            }

            if (flag)
            {
                return(par1ItemStack);
            }

            if (movingobjectposition.TypeOfHit == EnumMovingObjectType.TILE)
            {
                int i = movingobjectposition.BlockX;
                int j = movingobjectposition.BlockY;
                int k = movingobjectposition.BlockZ;

                if (!par2World.IsRemote)
                {
                    if (par2World.GetBlockId(i, j, k) == Block.Snow.BlockID)
                    {
                        j--;
                    }

                    par2World.SpawnEntityInWorld(new EntityBoat(par2World, (float)i + 0.5F, (float)j + 1.0F, (float)k + 0.5F));
                }

                if (!par3EntityPlayer.Capabilities.IsCreativeMode)
                {
                    par1ItemStack.StackSize--;
                }
            }

            return(par1ItemStack);
        }
Пример #18
0
        /// <summary>
        /// Returns a vector indicating the direction and intensity of fluid flow.
        /// </summary>
        private Vec3D GetFlowVector(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
        {
            Vec3D vec3d = Vec3D.CreateVector(0.0F, 0.0F, 0.0F);
            int   i     = GetEffectiveFlowDecay(par1IBlockAccess, par2, par3, par4);

            for (int j = 0; j < 4; j++)
            {
                int k  = par2;
                int l  = par3;
                int i1 = par4;

                if (j == 0)
                {
                    k--;
                }

                if (j == 1)
                {
                    i1--;
                }

                if (j == 2)
                {
                    k++;
                }

                if (j == 3)
                {
                    i1++;
                }

                int j1 = GetEffectiveFlowDecay(par1IBlockAccess, k, l, i1);

                if (j1 < 0)
                {
                    if (par1IBlockAccess.GetBlockMaterial(k, l, i1).BlocksMovement())
                    {
                        continue;
                    }

                    j1 = GetEffectiveFlowDecay(par1IBlockAccess, k, l - 1, i1);

                    if (j1 >= 0)
                    {
                        int k1 = j1 - (i - 8);
                        vec3d = vec3d.AddVector((k - par2) * k1, (l - par3) * k1, (i1 - par4) * k1);
                    }

                    continue;
                }

                if (j1 >= 0)
                {
                    int l1 = j1 - i;
                    vec3d = vec3d.AddVector((k - par2) * l1, (l - par3) * l1, (i1 - par4) * l1);
                }
            }

            if (par1IBlockAccess.GetBlockMetadata(par2, par3, par4) >= 8)
            {
                bool flag = false;

                if (flag || IsBlockSolid(par1IBlockAccess, par2, par3, par4 - 1, 2))
                {
                    flag = true;
                }

                if (flag || IsBlockSolid(par1IBlockAccess, par2, par3, par4 + 1, 3))
                {
                    flag = true;
                }

                if (flag || IsBlockSolid(par1IBlockAccess, par2 - 1, par3, par4, 4))
                {
                    flag = true;
                }

                if (flag || IsBlockSolid(par1IBlockAccess, par2 + 1, par3, par4, 5))
                {
                    flag = true;
                }

                if (flag || IsBlockSolid(par1IBlockAccess, par2, par3 + 1, par4 - 1, 2))
                {
                    flag = true;
                }

                if (flag || IsBlockSolid(par1IBlockAccess, par2, par3 + 1, par4 + 1, 3))
                {
                    flag = true;
                }

                if (flag || IsBlockSolid(par1IBlockAccess, par2 - 1, par3 + 1, par4, 4))
                {
                    flag = true;
                }

                if (flag || IsBlockSolid(par1IBlockAccess, par2 + 1, par3 + 1, par4, 5))
                {
                    flag = true;
                }

                if (flag)
                {
                    vec3d = vec3d.Normalize().AddVector(0.0F, -6D, 0.0F);
                }
            }

            vec3d = vec3d.Normalize();
            return(vec3d);
        }
Пример #19
0
        /// <summary>
        /// Called to update the entity's position/logic.
        /// </summary>
        public override void OnUpdate()
        {
            base.OnUpdate();

            if (FishPosRotationIncrements > 0)
            {
                float  d  = PosX + (FishX - PosX) / FishPosRotationIncrements;
                float  d1 = PosY + (FishY - PosY) / FishPosRotationIncrements;
                float  d2 = PosZ + (FishZ - PosZ) / FishPosRotationIncrements;
                double d4;

                for (d4 = FishYaw - RotationYaw; d4 < -180D; d4 += 360D)
                {
                }

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

                RotationYaw   += (float)d4 / FishPosRotationIncrements;
                RotationPitch += (float)(FishPitch - RotationPitch) / FishPosRotationIncrements;
                FishPosRotationIncrements--;
                SetPosition(d, d1, d2);
                SetRotation(RotationYaw, RotationPitch);
                return;
            }

            if (!WorldObj.IsRemote)
            {
                ItemStack itemstack = Angler.GetCurrentEquippedItem();

                if (Angler.IsDead || !Angler.IsEntityAlive() || itemstack == null || itemstack.GetItem() != Item.FishingRod || GetDistanceSqToEntity(Angler) > 1024D)
                {
                    SetDead();
                    Angler.FishEntity = null;
                    return;
                }

                if (Bobber != null)
                {
                    if (Bobber.IsDead)
                    {
                        Bobber = null;
                    }
                    else
                    {
                        PosX = Bobber.PosX;
                        PosY = Bobber.BoundingBox.MinY + Bobber.Height * 0.80000000000000004F;
                        PosZ = Bobber.PosZ;
                        return;
                    }
                }
            }

            if (Shake > 0)
            {
                Shake--;
            }

            if (InGround)
            {
                int i = WorldObj.GetBlockId(XTile, YTile, ZTile);

                if (i != InTile)
                {
                    InGround      = false;
                    MotionX      *= Rand.NextFloat() * 0.2F;
                    MotionY      *= Rand.NextFloat() * 0.2F;
                    MotionZ      *= Rand.NextFloat() * 0.2F;
                    TicksInGround = 0;
                    TicksInAir    = 0;
                }
                else
                {
                    TicksInGround++;

                    if (TicksInGround == 1200)
                    {
                        SetDead();
                    }

                    return;
                }
            }
            else
            {
                TicksInAir++;
            }

            Vec3D vec3d  = Vec3D.CreateVector(PosX, PosY, PosZ);
            Vec3D vec3d1 = Vec3D.CreateVector(PosX + MotionX, PosY + MotionY, PosZ + MotionZ);
            MovingObjectPosition movingobjectposition = WorldObj.RayTraceBlocks(vec3d, vec3d1);

            vec3d  = Vec3D.CreateVector(PosX, PosY, PosZ);
            vec3d1 = Vec3D.CreateVector(PosX + MotionX, PosY + MotionY, PosZ + MotionZ);

            if (movingobjectposition != null)
            {
                vec3d1 = Vec3D.CreateVector(movingobjectposition.HitVec.XCoord, movingobjectposition.HitVec.YCoord, movingobjectposition.HitVec.ZCoord);
            }

            Entity        entity = null;
            List <Entity> list   = WorldObj.GetEntitiesWithinAABBExcludingEntity(this, BoundingBox.AddCoord(MotionX, MotionY, MotionZ).Expand(1.0F, 1.0F, 1.0F));
            double        d3     = 0.0F;

            for (int j = 0; j < list.Count; j++)
            {
                Entity entity1 = list[j];

                if (!entity1.CanBeCollidedWith() || entity1 == Angler && TicksInAir < 5)
                {
                    continue;
                }

                float                f2                    = 0.3F;
                AxisAlignedBB        axisalignedbb         = entity1.BoundingBox.Expand(f2, f2, f2);
                MovingObjectPosition movingobjectposition1 = axisalignedbb.CalculateIntercept(vec3d, vec3d1);

                if (movingobjectposition1 == null)
                {
                    continue;
                }

                double d6 = vec3d.DistanceTo(movingobjectposition1.HitVec);

                if (d6 < d3 || d3 == 0.0F)
                {
                    entity = entity1;
                    d3     = d6;
                }
            }

            if (entity != null)
            {
                movingobjectposition = new MovingObjectPosition(entity);
            }

            if (movingobjectposition != null)
            {
                if (movingobjectposition.EntityHit != null)
                {
                    if (movingobjectposition.EntityHit.AttackEntityFrom(DamageSource.CauseThrownDamage(this, Angler), 0))
                    {
                        Bobber = movingobjectposition.EntityHit;
                    }
                }
                else
                {
                    InGround = true;
                }
            }

            if (InGround)
            {
                return;
            }

            MoveEntity(MotionX, MotionY, MotionZ);
            float f = MathHelper2.Sqrt_double(MotionX * MotionX + MotionZ * MotionZ);

            RotationYaw = (float)((Math.Atan2(MotionX, MotionZ) * 180D) / Math.PI);

            for (RotationPitch = (float)((Math.Atan2(MotionY, f) * 180D) / Math.PI); RotationPitch - PrevRotationPitch < -180F; PrevRotationPitch -= 360F)
            {
            }

            for (; RotationPitch - PrevRotationPitch >= 180F; PrevRotationPitch += 360F)
            {
            }

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

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

            RotationPitch = PrevRotationPitch + (RotationPitch - PrevRotationPitch) * 0.2F;
            RotationYaw   = PrevRotationYaw + (RotationYaw - PrevRotationYaw) * 0.2F;
            float f1 = 0.92F;

            if (OnGround || IsCollidedHorizontally)
            {
                f1 = 0.5F;
            }

            int   k  = 5;
            float d5 = 0.0F;

            for (int l = 0; l < k; l++)
            {
                float         d8             = ((BoundingBox.MinY + ((BoundingBox.MaxY - BoundingBox.MinY) * (l + 0)) / k) - 0.125F) + 0.125F;
                float         d9             = ((BoundingBox.MinY + ((BoundingBox.MaxY - BoundingBox.MinY) * (l + 1)) / k) - 0.125F) + 0.125F;
                AxisAlignedBB axisalignedbb1 = AxisAlignedBB.GetBoundingBoxFromPool(BoundingBox.MinX, d8, BoundingBox.MinZ, BoundingBox.MaxX, d9, BoundingBox.MaxZ);

                if (WorldObj.IsAABBInMaterial(axisalignedbb1, Material.Water))
                {
                    d5 += 1.0F / k;
                }
            }

            if (d5 > 0.0F)
            {
                if (TicksCatchable > 0)
                {
                    TicksCatchable--;
                }
                else
                {
                    int c = 500;

                    if (WorldObj.CanLightningStrikeAt(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(PosY) + 1, MathHelper2.Floor_double(PosZ)))
                    {
                        c = 300;
                    }

                    if (Rand.Next(c) == 0)
                    {
                        TicksCatchable = Rand.Next(30) + 10;
                        MotionY       -= 0.20000000298023224F;
                        WorldObj.PlaySoundAtEntity(this, "random.splash", 0.25F, 1.0F + (Rand.NextFloat() - Rand.NextFloat()) * 0.4F);
                        float f3 = MathHelper2.Floor_double(BoundingBox.MinY);

                        for (int i1 = 0; (float)i1 < 1.0F + Width * 20F; i1++)
                        {
                            float f4 = (Rand.NextFloat() * 2.0F - 1.0F) * Width;
                            float f6 = (Rand.NextFloat() * 2.0F - 1.0F) * Width;
                            WorldObj.SpawnParticle("bubble", PosX + f4, f3 + 1.0F, PosZ + f6, MotionX, MotionY - (Rand.NextFloat() * 0.2F), MotionZ);
                        }

                        for (int j1 = 0; (float)j1 < 1.0F + Width * 20F; j1++)
                        {
                            float f5 = (Rand.NextFloat() * 2.0F - 1.0F) * Width;
                            float f7 = (Rand.NextFloat() * 2.0F - 1.0F) * Width;
                            WorldObj.SpawnParticle("splash", PosX + f5, f3 + 1.0F, PosZ + f7, MotionX, MotionY, MotionZ);
                        }
                    }
                }
            }

            if (TicksCatchable > 0)
            {
                MotionY -= (Rand.NextFloat() * Rand.NextFloat() * Rand.NextFloat()) * 0.20000000000000001F;
            }

            float d7 = d5 * 2F - 1.0F;

            MotionY += 0.039999999105930328F * d7;

            if (d5 > 0.0F)
            {
                f1       = (float)((double)f1 * 0.90000000000000002D);
                MotionY *= 0.80000000000000004F;
            }

            MotionX *= f1;
            MotionY *= f1;
            MotionZ *= f1;
            SetPosition(PosX, PosY, PosZ);
        }
Пример #20
0
        /// <summary>
        /// Does the first part of explosion (destroy blocks)
        /// </summary>
        public virtual void DoExplosionA()
        {
            float f = ExplosionSize;
            int   i = 16;

            for (int j = 0; j < i; j++)
            {
                for (int l = 0; l < i; l++)
                {
label0:

                    for (int j1 = 0; j1 < i; j1++)
                    {
                        if (j != 0 && j != i - 1 && l != 0 && l != i - 1 && j1 != 0 && j1 != i - 1)
                        {
                            continue;
                        }

                        double d  = ((float)j / ((float)i - 1.0F)) * 2.0F - 1.0F;
                        double d1 = ((float)l / ((float)i - 1.0F)) * 2.0F - 1.0F;
                        double d2 = ((float)j1 / ((float)i - 1.0F)) * 2.0F - 1.0F;
                        double d3 = Math.Sqrt(d * d + d1 * d1 + d2 * d2);
                        d  /= d3;
                        d1 /= d3;
                        d2 /= d3;
                        float  f1 = ExplosionSize * (0.7F + WorldObj.Rand.NextFloat() * 0.6F);
                        double d5 = ExplosionX;
                        double d7 = ExplosionY;
                        double d9 = ExplosionZ;
                        float  f2 = 0.3F;

                        do
                        {
                            if (f1 <= 0.0F)
                            {
                                goto label0;
                            }

                            int l2 = MathHelper2.Floor_double(d5);
                            int i3 = MathHelper2.Floor_double(d7);
                            int j3 = MathHelper2.Floor_double(d9);
                            int k3 = WorldObj.GetBlockId(l2, i3, j3);

                            if (k3 > 0)
                            {
                                f1 -= (Block.BlocksList[k3].GetExplosionResistance(Exploder) + 0.3F) * f2;
                            }

                            if (f1 > 0.0F)
                            {
                                DestroyedBlockPositions.Add(new ChunkPosition(l2, i3, j3));
                            }

                            d5 += d * (double)f2;
                            d7 += d1 * (double)f2;
                            d9 += d2 * (double)f2;
                            f1 -= f2 * 0.75F;
                        }while (true);
                    }
                }
            }

            ExplosionSize *= 2.0F;
            int           k     = MathHelper2.Floor_double(ExplosionX - ExplosionSize - 1.0D);
            int           i1    = MathHelper2.Floor_double(ExplosionX + ExplosionSize + 1.0D);
            int           k1    = MathHelper2.Floor_double(ExplosionY - ExplosionSize - 1.0D);
            int           l1    = MathHelper2.Floor_double(ExplosionY + ExplosionSize + 1.0D);
            int           i2    = MathHelper2.Floor_double(ExplosionZ - ExplosionSize - 1.0D);
            int           j2    = MathHelper2.Floor_double(ExplosionZ + ExplosionSize + 1.0D);
            List <Entity> list  = WorldObj.GetEntitiesWithinAABBExcludingEntity(Exploder, AxisAlignedBB.GetBoundingBoxFromPool(k, k1, i2, i1, l1, j2));
            Vec3D         vec3d = Vec3D.CreateVector(ExplosionX, ExplosionY, ExplosionZ);

            for (int k2 = 0; k2 < list.Count; k2++)
            {
                Entity entity = list[k2];
                float  d4     = (float)entity.GetDistance(ExplosionX, ExplosionY, ExplosionZ) / ExplosionSize;

                if (d4 <= 1.0D)
                {
                    float d6  = entity.PosX - ExplosionX;
                    float d8  = entity.PosY - ExplosionY;
                    float d10 = entity.PosZ - ExplosionZ;
                    float d11 = MathHelper2.Sqrt_double(d6 * d6 + d8 * d8 + d10 * d10);
                    d6  /= d11;
                    d8  /= d11;
                    d10 /= d11;
                    float d12 = WorldObj.GetBlockDensity(vec3d, entity.BoundingBox);
                    float d13 = (1.0F - d4) * d12;
                    entity.AttackEntityFrom(DamageSource.Explosion, (int)(((d13 * d13 + d13) / 2D) * 8D * ExplosionSize + 1.0D));
                    float d14 = d13;
                    entity.MotionX += d6 * d14;
                    entity.MotionY += d8 * d14;
                    entity.MotionZ += d10 * d14;
                }
            }

            ExplosionSize = f;
            List <ChunkPosition> arraylist = new List <ChunkPosition>();

            arraylist.AddRange(DestroyedBlockPositions);
        }
Пример #21
0
        /// <summary>
        /// Called to update the entity's position/logic.
        /// </summary>
        public override void OnUpdate()
        {
            base.OnUpdate();

            if (PrevRotationPitch == 0.0F && PrevRotationYaw == 0.0F)
            {
                float f = MathHelper2.Sqrt_double(MotionX * MotionX + MotionZ * MotionZ);
                PrevRotationYaw   = RotationYaw = (float)((Math.Atan2(MotionX, MotionZ) * 180D) / Math.PI);
                PrevRotationPitch = RotationPitch = (float)((Math.Atan2(MotionY, f) * 180D) / Math.PI);
            }

            int i = WorldObj.GetBlockId(XTile, YTile, ZTile);

            if (i > 0)
            {
                Block.BlocksList[i].SetBlockBoundsBasedOnState(WorldObj, XTile, YTile, ZTile);
                AxisAlignedBB axisalignedbb = Block.BlocksList[i].GetCollisionBoundingBoxFromPool(WorldObj, XTile, YTile, ZTile);

                if (axisalignedbb != null && axisalignedbb.IsVecInside(Vec3D.CreateVector(PosX, PosY, PosZ)))
                {
                    InGround = true;
                }
            }

            if (ArrowShake > 0)
            {
                ArrowShake--;
            }

            if (InGround)
            {
                int j = WorldObj.GetBlockId(XTile, YTile, ZTile);
                int k = WorldObj.GetBlockMetadata(XTile, YTile, ZTile);

                if (j != InTile || k != InData)
                {
                    InGround      = false;
                    MotionX      *= Rand.NextFloat() * 0.2F;
                    MotionY      *= Rand.NextFloat() * 0.2F;
                    MotionZ      *= Rand.NextFloat() * 0.2F;
                    TicksInGround = 0;
                    TicksInAir    = 0;
                    return;
                }

                TicksInGround++;

                if (TicksInGround == 1200)
                {
                    SetDead();
                }

                return;
            }

            TicksInAir++;
            Vec3D vec3d  = Vec3D.CreateVector(PosX, PosY, PosZ);
            Vec3D vec3d1 = Vec3D.CreateVector(PosX + MotionX, PosY + MotionY, PosZ + MotionZ);
            MovingObjectPosition movingobjectposition = WorldObj.RayTraceBlocks_do_do(vec3d, vec3d1, false, true);

            vec3d  = Vec3D.CreateVector(PosX, PosY, PosZ);
            vec3d1 = Vec3D.CreateVector(PosX + MotionX, PosY + MotionY, PosZ + MotionZ);

            if (movingobjectposition != null)
            {
                vec3d1 = Vec3D.CreateVector(movingobjectposition.HitVec.XCoord, movingobjectposition.HitVec.YCoord, movingobjectposition.HitVec.ZCoord);
            }

            Entity        entity = null;
            List <Entity> list   = WorldObj.GetEntitiesWithinAABBExcludingEntity(this, BoundingBox.AddCoord(MotionX, MotionY, MotionZ).Expand(1.0F, 1.0F, 1.0F));
            double        d      = 0.0F;

            for (int l = 0; l < list.Count; l++)
            {
                Entity entity1 = list[l];

                if (!entity1.CanBeCollidedWith() || entity1 == ShootingEntity && TicksInAir < 5)
                {
                    continue;
                }

                float                f5                    = 0.3F;
                AxisAlignedBB        axisalignedbb1        = entity1.BoundingBox.Expand(f5, f5, f5);
                MovingObjectPosition movingobjectposition1 = axisalignedbb1.CalculateIntercept(vec3d, vec3d1);

                if (movingobjectposition1 == null)
                {
                    continue;
                }

                double d1 = vec3d.DistanceTo(movingobjectposition1.HitVec);

                if (d1 < d || d == 0.0F)
                {
                    entity = entity1;
                    d      = d1;
                }
            }

            if (entity != null)
            {
                movingobjectposition = new MovingObjectPosition(entity);
            }

            if (movingobjectposition != null)
            {
                if (movingobjectposition.EntityHit != null)
                {
                    float f1 = MathHelper2.Sqrt_double(MotionX * MotionX + MotionY * MotionY + MotionZ * MotionZ);
                    int   j1 = (int)Math.Ceiling((double)f1 * Damage);

                    if (ArrowCritical)
                    {
                        j1 += Rand.Next(j1 / 2 + 2);
                    }

                    DamageSource damagesource = null;

                    if (ShootingEntity == null)
                    {
                        damagesource = DamageSource.CauseArrowDamage(this, this);
                    }
                    else
                    {
                        damagesource = DamageSource.CauseArrowDamage(this, ShootingEntity);
                    }

                    if (IsBurning())
                    {
                        movingobjectposition.EntityHit.SetFire(5);
                    }

                    if (movingobjectposition.EntityHit.AttackEntityFrom(damagesource, j1))
                    {
                        if (movingobjectposition.EntityHit is EntityLiving)
                        {
                            ((EntityLiving)movingobjectposition.EntityHit).ArrowHitTempCounter++;

                            if (Field_46027_au > 0)
                            {
                                float f7 = MathHelper2.Sqrt_double(MotionX * MotionX + MotionZ * MotionZ);

                                if (f7 > 0.0F)
                                {
                                    movingobjectposition.EntityHit.AddVelocity((MotionX * Field_46027_au * 0.60000002384185791F) / f7, 0.10000000000000001F, (MotionZ * Field_46027_au * 0.60000002384185791F) / f7);
                                }
                            }
                        }

                        WorldObj.PlaySoundAtEntity(this, "random.bowhit", 1.0F, 1.2F / (Rand.NextFloat() * 0.2F + 0.9F));
                        SetDead();
                    }
                    else
                    {
                        MotionX         *= -0.10000000149011612F;
                        MotionY         *= -0.10000000149011612F;
                        MotionZ         *= -0.10000000149011612F;
                        RotationYaw     += 180F;
                        PrevRotationYaw += 180F;
                        TicksInAir       = 0;
                    }
                }
                else
                {
                    XTile   = movingobjectposition.BlockX;
                    YTile   = movingobjectposition.BlockY;
                    ZTile   = movingobjectposition.BlockZ;
                    InTile  = WorldObj.GetBlockId(XTile, YTile, ZTile);
                    InData  = WorldObj.GetBlockMetadata(XTile, YTile, ZTile);
                    MotionX = (float)(movingobjectposition.HitVec.XCoord - PosX);
                    MotionY = (float)(movingobjectposition.HitVec.YCoord - PosY);
                    MotionZ = (float)(movingobjectposition.HitVec.ZCoord - PosZ);
                    float f2 = MathHelper2.Sqrt_double(MotionX * MotionX + MotionY * MotionY + MotionZ * MotionZ);
                    PosX -= (MotionX / f2) * 0.05000000074505806F;
                    PosY -= (MotionY / f2) * 0.05000000074505806F;
                    PosZ -= (MotionZ / f2) * 0.05000000074505806F;
                    WorldObj.PlaySoundAtEntity(this, "random.bowhit", 1.0F, 1.2F / (Rand.NextFloat() * 0.2F + 0.9F));
                    InGround      = true;
                    ArrowShake    = 7;
                    ArrowCritical = false;
                }
            }

            if (ArrowCritical)
            {
                for (int i1 = 0; i1 < 4; i1++)
                {
                    WorldObj.SpawnParticle("crit", PosX + (MotionX * (double)i1) / 4D, PosY + (MotionY * (double)i1) / 4D, PosZ + (MotionZ * (double)i1) / 4D, -MotionX, -MotionY + 0.20000000000000001D, -MotionZ);
                }
            }

            PosX += MotionX;
            PosY += MotionY;
            PosZ += MotionZ;
            float f3 = MathHelper2.Sqrt_double(MotionX * MotionX + MotionZ * MotionZ);

            RotationYaw = (float)((Math.Atan2(MotionX, MotionZ) * 180D) / Math.PI);

            for (RotationPitch = (float)((Math.Atan2(MotionY, f3) * 180D) / Math.PI); RotationPitch - PrevRotationPitch < -180F; PrevRotationPitch -= 360F)
            {
            }

            for (; RotationPitch - PrevRotationPitch >= 180F; PrevRotationPitch += 360F)
            {
            }

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

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

            RotationPitch = PrevRotationPitch + (RotationPitch - PrevRotationPitch) * 0.2F;
            RotationYaw   = PrevRotationYaw + (RotationYaw - PrevRotationYaw) * 0.2F;
            float f4 = 0.99F;
            float f6 = 0.05F;

            if (IsInWater())
            {
                for (int k1 = 0; k1 < 4; k1++)
                {
                    float f8 = 0.25F;
                    WorldObj.SpawnParticle("bubble", PosX - MotionX * (double)f8, PosY - MotionY * (double)f8, PosZ - MotionZ * (double)f8, MotionX, MotionY, MotionZ);
                }

                f4 = 0.8F;
            }

            MotionX *= f4;
            MotionY *= f4;
            MotionZ *= f4;
            MotionY -= f6;
            SetPosition(PosX, PosY, PosZ);
        }
 private Vec3D GetEntityPosition()
 {
     return(Vec3D.CreateVector(TheEntity.PosX, GetPathableYPos(), TheEntity.PosZ));
 }
Пример #23
0
        /// <summary>
        /// Called to update the entity's position/logic.
        /// </summary>
        public override void OnUpdate()
        {
            if (!WorldObj.IsRemote && (ShootingEntity != null && ShootingEntity.IsDead || !WorldObj.BlockExists((int)PosX, (int)PosY, (int)PosZ)))
            {
                SetDead();
                return;
            }

            base.OnUpdate();
            SetFire(1);

            if (InGround)
            {
                int i = WorldObj.GetBlockId(XTile, YTile, ZTile);

                if (i != InTile)
                {
                    InGround   = false;
                    MotionX   *= Rand.NextFloat() * 0.2F;
                    MotionY   *= Rand.NextFloat() * 0.2F;
                    MotionZ   *= Rand.NextFloat() * 0.2F;
                    TicksAlive = 0;
                    TicksInAir = 0;
                }
                else
                {
                    TicksAlive++;

                    if (TicksAlive == 600)
                    {
                        SetDead();
                    }

                    return;
                }
            }
            else
            {
                TicksInAir++;
            }

            Vec3D vec3d  = Vec3D.CreateVector(PosX, PosY, PosZ);
            Vec3D vec3d1 = Vec3D.CreateVector(PosX + MotionX, PosY + MotionY, PosZ + MotionZ);
            MovingObjectPosition movingobjectposition = WorldObj.RayTraceBlocks(vec3d, vec3d1);

            vec3d  = Vec3D.CreateVector(PosX, PosY, PosZ);
            vec3d1 = Vec3D.CreateVector(PosX + MotionX, PosY + MotionY, PosZ + MotionZ);

            if (movingobjectposition != null)
            {
                vec3d1 = Vec3D.CreateVector(movingobjectposition.HitVec.XCoord, movingobjectposition.HitVec.YCoord, movingobjectposition.HitVec.ZCoord);
            }

            Entity        entity = null;
            List <Entity> list   = WorldObj.GetEntitiesWithinAABBExcludingEntity(this, BoundingBox.AddCoord(MotionX, MotionY, MotionZ).Expand(1.0F, 1.0F, 1.0F));
            double        d      = 0.0F;

            for (int j = 0; j < list.Count; j++)
            {
                Entity entity1 = list[j];

                if (!entity1.CanBeCollidedWith() || entity1.IsEntityEqual(ShootingEntity) && TicksInAir < 25)
                {
                    continue;
                }

                float                f2                    = 0.3F;
                AxisAlignedBB        axisalignedbb         = entity1.BoundingBox.Expand(f2, f2, f2);
                MovingObjectPosition movingobjectposition1 = axisalignedbb.CalculateIntercept(vec3d, vec3d1);

                if (movingobjectposition1 == null)
                {
                    continue;
                }

                double d1 = vec3d.DistanceTo(movingobjectposition1.HitVec);

                if (d1 < d || d == 0.0F)
                {
                    entity = entity1;
                    d      = d1;
                }
            }

            if (entity != null)
            {
                movingobjectposition = new MovingObjectPosition(entity);
            }

            if (movingobjectposition != null)
            {
                Func_40071_a(movingobjectposition);
            }

            PosX += MotionX;
            PosY += MotionY;
            PosZ += MotionZ;
            float f = MathHelper2.Sqrt_double(MotionX * MotionX + MotionZ * MotionZ);

            RotationYaw = (float)((Math.Atan2(MotionX, MotionZ) * 180D) / Math.PI);

            for (RotationPitch = (float)((Math.Atan2(MotionY, f) * 180D) / Math.PI); RotationPitch - PrevRotationPitch < -180F; PrevRotationPitch -= 360F)
            {
            }

            for (; RotationPitch - PrevRotationPitch >= 180F; PrevRotationPitch += 360F)
            {
            }

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

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

            RotationPitch = PrevRotationPitch + (RotationPitch - PrevRotationPitch) * 0.2F;
            RotationYaw   = PrevRotationYaw + (RotationYaw - PrevRotationYaw) * 0.2F;
            float f1 = 0.95F;

            if (IsInWater())
            {
                for (int k = 0; k < 4; k++)
                {
                    float f3 = 0.25F;
                    WorldObj.SpawnParticle("bubble", PosX - MotionX * (double)f3, PosY - MotionY * (double)f3, PosZ - MotionZ * (double)f3, MotionX, MotionY, MotionZ);
                }

                f1 = 0.8F;
            }

            MotionX += AccelerationX;
            MotionY += AccelerationY;
            MotionZ += AccelerationZ;
            MotionX *= f1;
            MotionY *= f1;
            MotionZ *= f1;
            WorldObj.SpawnParticle("smoke", PosX, PosY + 0.5D, PosZ, 0.0F, 0.0F, 0.0F);
            SetPosition(PosX, PosY, PosZ);
        }
Пример #24
0
        /// <summary>
        /// Actually renders the fishing line and hook
        /// </summary>
        public virtual void DoRenderFishHook(EntityFishHook par1EntityFishHook, double par2, double par4, double par6, float par8, float par9)
        {
            //GL.PushMatrix();
            //GL.Translate((float)par2, (float)par4, (float)par6);
            //GL.Enable(EnableCap.RescaleNormal);
            //GL.Scale(0.5F, 0.5F, 0.5F);
            int   i     = 1;
            sbyte byte0 = 2;

            LoadTexture("/particles.png");
            Tessellator tessellator = Tessellator.Instance;
            float       f           = (float)(i * 8 + 0) / 128F;
            float       f1          = (float)(i * 8 + 8) / 128F;
            float       f2          = (float)(byte0 * 8 + 0) / 128F;
            float       f3          = (float)(byte0 * 8 + 8) / 128F;
            float       f4          = 1.0F;
            float       f5          = 0.5F;
            float       f6          = 0.5F;

            //GL.Rotate(180F - RenderManager.PlayerViewY, 0.0F, 1.0F, 0.0F);
            //GL.Rotate(-RenderManager.PlayerViewX, 1.0F, 0.0F, 0.0F);
            tessellator.StartDrawingQuads();
            tessellator.SetNormal(0.0F, 1.0F, 0.0F);
            tessellator.AddVertexWithUV(0.0F - f5, 0.0F - f6, 0.0F, f, f3);
            tessellator.AddVertexWithUV(f4 - f5, 0.0F - f6, 0.0F, f1, f3);
            tessellator.AddVertexWithUV(f4 - f5, 1.0F - f6, 0.0F, f1, f2);
            tessellator.AddVertexWithUV(0.0F - f5, 1.0F - f6, 0.0F, f, f2);
            tessellator.Draw();
            //GL.Disable(EnableCap.RescaleNormal);
            //GL.PopMatrix();

            if (par1EntityFishHook.Angler != null)
            {
                float  f7    = ((par1EntityFishHook.Angler.PrevRotationYaw + (par1EntityFishHook.Angler.RotationYaw - par1EntityFishHook.Angler.PrevRotationYaw) * par9) * (float)Math.PI) / 180F;
                double d     = MathHelper2.Sin(f7);
                double d2    = MathHelper2.Cos(f7);
                float  f9    = par1EntityFishHook.Angler.GetSwingProgress(par9);
                float  f10   = MathHelper2.Sin(MathHelper2.Sqrt_float(f9) * (float)Math.PI);
                Vec3D  vec3d = Vec3D.CreateVector(-0.5D, 0.029999999999999999D, 0.80000000000000004D);
                vec3d.RotateAroundX((-(par1EntityFishHook.Angler.PrevRotationPitch + (par1EntityFishHook.Angler.RotationPitch - par1EntityFishHook.Angler.PrevRotationPitch) * par9) * (float)Math.PI) / 180F);
                vec3d.RotateAroundY((-(par1EntityFishHook.Angler.PrevRotationYaw + (par1EntityFishHook.Angler.RotationYaw - par1EntityFishHook.Angler.PrevRotationYaw) * par9) * (float)Math.PI) / 180F);
                vec3d.RotateAroundY(f10 * 0.5F);
                vec3d.RotateAroundX(-f10 * 0.7F);
                double d4 = par1EntityFishHook.Angler.PrevPosX + (par1EntityFishHook.Angler.PosX - par1EntityFishHook.Angler.PrevPosX) * (double)par9 + vec3d.XCoord;
                double d5 = par1EntityFishHook.Angler.PrevPosY + (par1EntityFishHook.Angler.PosY - par1EntityFishHook.Angler.PrevPosY) * (double)par9 + vec3d.YCoord;
                double d6 = par1EntityFishHook.Angler.PrevPosZ + (par1EntityFishHook.Angler.PosZ - par1EntityFishHook.Angler.PrevPosZ) * (double)par9 + vec3d.ZCoord;

                if (RenderManager.Options.ThirdPersonView > 0)
                {
                    float  f8 = ((par1EntityFishHook.Angler.PrevRenderYawOffset + (par1EntityFishHook.Angler.RenderYawOffset - par1EntityFishHook.Angler.PrevRenderYawOffset) * par9) * (float)Math.PI) / 180F;
                    double d1 = MathHelper2.Sin(f8);
                    double d3 = MathHelper2.Cos(f8);
                    d4 = (par1EntityFishHook.Angler.PrevPosX + (par1EntityFishHook.Angler.PosX - par1EntityFishHook.Angler.PrevPosX) * (double)par9) - d3 * 0.34999999999999998D - d1 * 0.84999999999999998D;
                    d5 = (par1EntityFishHook.Angler.PrevPosY + (par1EntityFishHook.Angler.PosY - par1EntityFishHook.Angler.PrevPosY) * (double)par9) - 0.45000000000000001D;
                    d6 = ((par1EntityFishHook.Angler.PrevPosZ + (par1EntityFishHook.Angler.PosZ - par1EntityFishHook.Angler.PrevPosZ) * (double)par9) - d1 * 0.34999999999999998D) + d3 * 0.84999999999999998D;
                }

                double d7  = par1EntityFishHook.PrevPosX + (par1EntityFishHook.PosX - par1EntityFishHook.PrevPosX) * (double)par9;
                double d8  = par1EntityFishHook.PrevPosY + (par1EntityFishHook.PosY - par1EntityFishHook.PrevPosY) * (double)par9 + 0.25D;
                double d9  = par1EntityFishHook.PrevPosZ + (par1EntityFishHook.PosZ - par1EntityFishHook.PrevPosZ) * (double)par9;
                double d10 = (float)(d4 - d7);
                double d11 = (float)(d5 - d8);
                double d12 = (float)(d6 - d9);
                //GL.Disable(EnableCap.Texture2D);
                //GL.Disable(EnableCap.Lighting);
                tessellator.StartDrawing(3);
                tessellator.SetColorOpaque_I(0);
                int j = 16;

                for (int k = 0; k <= j; k++)
                {
                    float f11 = (float)k / (float)j;
                    tessellator.AddVertex(par2 + d10 * (double)f11, par4 + d11 * (double)(f11 * f11 + f11) * 0.5D + 0.25D, par6 + d12 * (double)f11);
                }

                tessellator.Draw();
                //GL.Enable(EnableCap.Lighting);
                //GL.Enable(EnableCap.Texture2D);
            }
        }
Пример #25
0
        private static Vec3D Func_48621_c(EntityCreature par0EntityCreature, int par1, int par2, Vec3D par3Vec3D)
        {
            Random random = par0EntityCreature.GetRNG();
            bool   flag   = false;
            int    i      = 0;
            int    j      = 0;
            int    k      = 0;
            float  f      = -99999F;
            bool   flag1;

            if (par0EntityCreature.HasHome())
            {
                double d = par0EntityCreature.GetHomePosition().GetEuclideanDistanceTo(MathHelper2.Floor_double(par0EntityCreature.PosX), MathHelper2.Floor_double(par0EntityCreature.PosY), MathHelper2.Floor_double(par0EntityCreature.PosZ)) + 4D;
                flag1 = d < (double)(par0EntityCreature.GetMaximumHomeDistance() + (float)par1);
            }
            else
            {
                flag1 = false;
            }

            for (int l = 0; l < 10; l++)
            {
                int i1 = random.Next(2 * par1) - par1;
                int j1 = random.Next(2 * par2) - par2;
                int k1 = random.Next(2 * par1) - par1;

                if (par3Vec3D != null && (double)i1 * par3Vec3D.XCoord + (double)k1 * par3Vec3D.ZCoord < 0.0F)
                {
                    continue;
                }

                i1 += MathHelper2.Floor_double(par0EntityCreature.PosX);
                j1 += MathHelper2.Floor_double(par0EntityCreature.PosY);
                k1 += MathHelper2.Floor_double(par0EntityCreature.PosZ);

                if (flag1 && !par0EntityCreature.IsWithinHomeDistance(i1, j1, k1))
                {
                    continue;
                }

                float f1 = par0EntityCreature.GetBlockPathWeight(i1, j1, k1);

                if (f1 > f)
                {
                    f    = f1;
                    i    = i1;
                    j    = j1;
                    k    = k1;
                    flag = true;
                }
            }

            if (flag)
            {
                return(Vec3D.CreateVector(i, j, k));
            }
            else
            {
                return(null);
            }
        }