/// <summary>
 /// Sets a new position for the renderer and setting it up so it can be reloaded with the new data for that position
 /// </summary>
 public void SetPosition(int par1, int par2, int par3)
 {
     if (par1 == PosX && par2 == PosY && par3 == PosZ)
     {
         return;
     }
     else
     {
         SetDontDraw();
         PosX      = par1;
         PosY      = par2;
         PosZ      = par3;
         PosXPlus  = par1 + 8;
         PosYPlus  = par2 + 8;
         PosZPlus  = par3 + 8;
         PosXClip  = par1 & 0x3ff;
         PosYClip  = par2;
         PosZClip  = par3 & 0x3ff;
         PosXMinus = par1 - PosXClip;
         PosYMinus = par2 - PosYClip;
         PosZMinus = par3 - PosZClip;
         float f = 6F;
         RendererBoundingBox = AxisAlignedBB.GetBoundingBox(par1 - f, par2 - f, par3 - f, (par1 + 16) + f, (par2 + 16) + f, (par3 + 16) + f);
         //GL.NewList(GlRenderList + 2, ListMode.Compile);
         RenderItem.RenderAABB(AxisAlignedBB.GetBoundingBoxFromPool(PosXClip - f, PosYClip - f, PosZClip - f, (PosXClip + 16) + f, (PosYClip + 16) + f, (PosZClip + 16) + f));
         //GL.EndList();
         MarkDirty();
         return;
     }
 }
Beispiel #2
0
        /// <summary>
        /// Returns the bounding box of the wired rectangular prism to render.
        /// </summary>
        public override AxisAlignedBB GetSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
        {
            int   i  = par1World.GetBlockMetadata(par2, par3, par4);
            float f  = 0.0625F;
            float f1 = (float)(1 + i * 2) / 16F;
            float f2 = 0.5F;

            return(AxisAlignedBB.GetBoundingBoxFromPool((float)par2 + f1, par3, (float)par4 + f, (float)(par2 + 1) - f, (float)par3 + f2, (float)(par4 + 1) - f));
        }
        /// <summary>
        /// Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
        /// cleared to be reused)
        /// </summary>
        public override AxisAlignedBB GetCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
        {
            int i = par1World.GetBlockMetadata(par2, par3, par4) & 7;

            if (i >= 3)
            {
                return(AxisAlignedBB.GetBoundingBoxFromPool(par2 + MinX, par3 + MinY, par4 + MinZ, par2 + MaxX, par3 + 0.5F, par4 + MaxZ));
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// Checks if there are mobs on the plate. If a mob is on the plate and it is off, it turns it on, and vice versa.
        /// </summary>
        private void SetStateIfMobInteractsWithPlate(World par1World, int par2, int par3, int par4)
        {
            bool          flag  = par1World.GetBlockMetadata(par2, par3, par4) == 1;
            bool          flag1 = false;
            float         f     = 0.125F;
            List <Entity> list  = null;

            if (TriggerMobType == EnumMobType.everything)
            {
                list = par1World.GetEntitiesWithinAABBExcludingEntity(null, AxisAlignedBB.GetBoundingBoxFromPool(par2 + f, par3, par4 + f, (par2 + 1) - f, par3 + 0.25F, (par4 + 1) - f));
            }

            if (TriggerMobType == EnumMobType.mobs)
            {
                list = par1World.GetEntitiesWithinAABB(typeof(net.minecraft.src.EntityLiving), AxisAlignedBB.GetBoundingBoxFromPool(par2 + f, par3, par4 + f, (par2 + 1) - f, par3 + 0.25F, (par4 + 1) - f));
            }

            if (TriggerMobType == EnumMobType.players)
            {
                list = par1World.GetEntitiesWithinAABB(typeof(net.minecraft.src.EntityPlayer), AxisAlignedBB.GetBoundingBoxFromPool(par2 + f, par3, par4 + f, (par2 + 1) - f, par3 + 0.25F, (par4 + 1) - f));
            }

            if (list.Count > 0)
            {
                flag1 = true;
            }

            if (flag1 && !flag)
            {
                par1World.SetBlockMetadataWithNotify(par2, par3, par4, 1);
                par1World.NotifyBlocksOfNeighborChange(par2, par3, par4, BlockID);
                par1World.NotifyBlocksOfNeighborChange(par2, par3 - 1, par4, BlockID);
                par1World.MarkBlocksDirty(par2, par3, par4, par2, par3, par4);
                par1World.PlaySoundEffect((double)par2 + 0.5D, (double)par3 + 0.10000000000000001D, (double)par4 + 0.5D, "random.click", 0.3F, 0.6F);
            }

            if (!flag1 && flag)
            {
                par1World.SetBlockMetadataWithNotify(par2, par3, par4, 0);
                par1World.NotifyBlocksOfNeighborChange(par2, par3, par4, BlockID);
                par1World.NotifyBlocksOfNeighborChange(par2, par3 - 1, par4, BlockID);
                par1World.MarkBlocksDirty(par2, par3, par4, par2, par3, par4);
                par1World.PlaySoundEffect((double)par2 + 0.5D, (double)par3 + 0.10000000000000001D, (double)par4 + 0.5D, "random.click", 0.3F, 0.5F);
            }

            if (flag1)
            {
                par1World.ScheduleBlockUpdate(par2, par3, par4, BlockID, TickRate());
            }
        }
Beispiel #5
0
        /// <summary>
        /// Called to update the entity's position/logic.
        /// </summary>
        public override void OnUpdate()
        {
            base.OnUpdate();

            if (LightningState == 2)
            {
                WorldObj.PlaySoundEffect(PosX, PosY, PosZ, "ambient.weather.thunder", 10000F, 0.8F + Rand.NextFloat() * 0.2F);
                WorldObj.PlaySoundEffect(PosX, PosY, PosZ, "random.explode", 2.0F, 0.5F + Rand.NextFloat() * 0.2F);
            }

            LightningState--;

            if (LightningState < 0)
            {
                if (BoltLivingTime == 0)
                {
                    SetDead();
                }
                else if (LightningState < -Rand.Next(10))
                {
                    BoltLivingTime--;
                    LightningState = 1;
                    BoltVertex     = Rand.Next();

                    if (WorldObj.DoChunksNearChunkExist(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(PosY), MathHelper2.Floor_double(PosZ), 10))
                    {
                        int i = MathHelper2.Floor_double(PosX);
                        int j = MathHelper2.Floor_double(PosY);
                        int k = MathHelper2.Floor_double(PosZ);

                        if (WorldObj.GetBlockId(i, j, k) == 0 && Block.Fire.CanPlaceBlockAt(WorldObj, i, j, k))
                        {
                            WorldObj.SetBlockWithNotify(i, j, k, Block.Fire.BlockID);
                        }
                    }
                }
            }

            if (LightningState >= 0)
            {
                float         d    = 3;
                List <Entity> list = WorldObj.GetEntitiesWithinAABBExcludingEntity(this, AxisAlignedBB.GetBoundingBoxFromPool(PosX - d, PosY - d, PosZ - d, PosX + d, PosY + 6 + d, PosZ + d));

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

                WorldObj.LightningFlash = 2;
            }
        }
        /// <summary>
        /// Returns the bounding box of the wired rectangular prism to render.
        /// </summary>
        public override AxisAlignedBB GetSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
        {
            float f = 0.0625F;

            return(AxisAlignedBB.GetBoundingBoxFromPool((float)par2 + f, par3, (float)par4 + f, (float)(par2 + 1) - f, par3 + 1, (float)(par4 + 1) - f));
        }
        private static bool Func_50075_j(World par0World, int par1, int par2, int par3)
        {
            for (IEnumerator <Entity> iterator = par0World.GetEntitiesWithinAABB(typeof(net.minecraft.src.EntityOcelot), AxisAlignedBB.GetBoundingBoxFromPool(par1, par2 + 1, par3, par1 + 1, par2 + 2, par3 + 1)).GetEnumerator(); iterator.MoveNext();)
            {
                Entity       entity       = iterator.Current;
                EntityOcelot entityocelot = (EntityOcelot)entity;

                if (entityocelot.IsSitting())
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #8
0
        /// <summary>
        /// Called to update the entity's position/logic.
        /// </summary>
        public override void OnUpdate()
        {
            base.OnUpdate();

            if (GetTimeSinceHit() > 0)
            {
                SetTimeSinceHit(GetTimeSinceHit() - 1);
            }

            if (GetDamageTaken() > 0)
            {
                SetDamageTaken(GetDamageTaken() - 1);
            }

            PrevPosX = PosX;
            PrevPosY = PosY;
            PrevPosZ = PosZ;
            int   i = 5;
            float d = 0.0F;

            for (int j = 0; j < i; j++)
            {
                float         d2            = (BoundingBox.MinY + ((BoundingBox.MaxY - BoundingBox.MinY) * (j + 0)) / i) - 0.125F;
                float         d8            = (BoundingBox.MinY + ((BoundingBox.MaxY - BoundingBox.MinY) * (j + 1)) / i) - 0.125F;
                AxisAlignedBB axisalignedbb = AxisAlignedBB.GetBoundingBoxFromPool(BoundingBox.MinX, d2, BoundingBox.MinZ, BoundingBox.MaxX, d8, BoundingBox.MaxZ);

                if (WorldObj.IsAABBInMaterial(axisalignedbb, Material.Water))
                {
                    d += 1.0F / i;
                }
            }

            double d1 = Math.Sqrt(MotionX * MotionX + MotionZ * MotionZ);

            if (d1 > 0.14999999999999999D)
            {
                double d3 = Math.Cos(((double)RotationYaw * Math.PI) / 180D);
                double d9 = Math.Sin(((double)RotationYaw * Math.PI) / 180D);

                for (int i1 = 0; (double)i1 < 1.0D + d1 * 60D; i1++)
                {
                    double d16 = Rand.NextFloat() * 2.0F - 1.0F;
                    double d19 = (double)(Rand.Next(2) * 2 - 1) * 0.69999999999999996D;

                    if (Rand.NextBool())
                    {
                        double d21 = (PosX - d3 * d16 * 0.80000000000000004D) + d9 * d19;
                        double d23 = PosZ - d9 * d16 * 0.80000000000000004D - d3 * d19;
                        WorldObj.SpawnParticle("splash", d21, PosY - 0.125D, d23, MotionX, MotionY, MotionZ);
                    }
                    else
                    {
                        double d22 = PosX + d3 + d9 * d16 * 0.69999999999999996D;
                        double d24 = (PosZ + d9) - d3 * d16 * 0.69999999999999996D;
                        WorldObj.SpawnParticle("splash", d22, PosY - 0.125D, d24, MotionX, MotionY, MotionZ);
                    }
                }
            }

            if (WorldObj.IsRemote)
            {
                if (BoatPosRotationIncrements > 0)
                {
                    float  d4  = PosX + (BoatX - PosX) / BoatPosRotationIncrements;
                    float  d10 = PosY + (BoatY - PosY) / BoatPosRotationIncrements;
                    float  d13 = PosZ + (BoatZ - PosZ) / BoatPosRotationIncrements;
                    double d17;

                    for (d17 = BoatYaw - (double)RotationYaw; d17 < -180D; d17 += 360D)
                    {
                    }

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

                    RotationYaw   += (float)d17 / BoatPosRotationIncrements;
                    RotationPitch += ((float)BoatPitch - RotationPitch) / BoatPosRotationIncrements;
                    BoatPosRotationIncrements--;
                    SetPosition(d4, d10, d13);
                    SetRotation(RotationYaw, RotationPitch);
                }
                else
                {
                    float d5  = PosX + MotionX;
                    float d11 = PosY + MotionY;
                    float d14 = PosZ + MotionZ;
                    SetPosition(d5, d11, d14);

                    if (OnGround)
                    {
                        MotionX *= 0.5F;
                        MotionY *= 0.5F;
                        MotionZ *= 0.5F;
                    }

                    MotionX *= 0.99000000953674316F;
                    MotionY *= 0.94999998807907104F;
                    MotionZ *= 0.99000000953674316F;
                }

                return;
            }

            if (d < 1.0F)
            {
                float d6 = d * 2F - 1.0F;
                MotionY += 0.039999999105930328F * d6;
            }
            else
            {
                if (MotionY < 0.0F)
                {
                    MotionY /= 2F;
                }

                MotionY += 0.0070000002160668373F;
            }

            if (RiddenByEntity != null)
            {
                MotionX += RiddenByEntity.MotionX * 0.20000000000000001F;
                MotionZ += RiddenByEntity.MotionZ * 0.20000000000000001F;
            }

            float d7 = 0.40000000000000002F;

            if (MotionX < -d7)
            {
                MotionX = -d7;
            }

            if (MotionX > d7)
            {
                MotionX = d7;
            }

            if (MotionZ < -d7)
            {
                MotionZ = -d7;
            }

            if (MotionZ > d7)
            {
                MotionZ = d7;
            }

            if (OnGround)
            {
                MotionX *= 0.5F;
                MotionY *= 0.5F;
                MotionZ *= 0.5F;
            }

            MoveEntity(MotionX, MotionY, MotionZ);

            if (IsCollidedHorizontally && d1 > 0.20000000000000001F)
            {
                if (!WorldObj.IsRemote)
                {
                    SetDead();

                    for (int k = 0; k < 3; k++)
                    {
                        DropItemWithOffset(Block.Planks.BlockID, 1, 0.0F);
                    }

                    for (int l = 0; l < 2; l++)
                    {
                        DropItemWithOffset(Item.Stick.ShiftedIndex, 1, 0.0F);
                    }
                }
            }
            else
            {
                MotionX *= 0.99000000953674316F;
                MotionY *= 0.94999998807907104F;
                MotionZ *= 0.99000000953674316F;
            }

            RotationPitch = 0.0F;
            double d12 = RotationYaw;
            double d15 = PrevPosX - PosX;
            double d18 = PrevPosZ - PosZ;

            if (d15 * d15 + d18 * d18 > 0.001D)
            {
                d12 = (float)((Math.Atan2(d18, d15) * 180D) / Math.PI);
            }

            double d20;

            for (d20 = d12 - (double)RotationYaw; d20 >= 180D; d20 -= 360D)
            {
            }

            for (; d20 < -180D; d20 += 360D)
            {
            }

            if (d20 > 20D)
            {
                d20 = 20D;
            }

            if (d20 < -20D)
            {
                d20 = -20D;
            }

            RotationYaw += (float)d20;
            SetRotation(RotationYaw, RotationPitch);
            List <Entity> list = WorldObj.GetEntitiesWithinAABBExcludingEntity(this, BoundingBox.Expand(0.20000000298023224F, 0.0F, 0.20000000298023224F));

            if (list != null && list.Count > 0)
            {
                for (int j1 = 0; j1 < list.Count; j1++)
                {
                    Entity entity = (Entity)list[j1];

                    if (entity != RiddenByEntity && entity.CanBePushed() && (entity is EntityBoat))
                    {
                        entity.ApplyEntityCollision(this);
                    }
                }
            }

            for (int k1 = 0; k1 < 4; k1++)
            {
                int l1 = MathHelper2.Floor_double(PosX + ((double)(k1 % 2) - 0.5D) * 0.80000000000000004D);
                int i2 = MathHelper2.Floor_double(PosY);
                int j2 = MathHelper2.Floor_double(PosZ + ((double)(k1 / 2) - 0.5D) * 0.80000000000000004D);

                if (WorldObj.GetBlockId(l1, i2, j2) == Block.Snow.BlockID)
                {
                    WorldObj.SetBlockWithNotify(l1, i2, j2, 0);
                }
            }

            if (RiddenByEntity != null && RiddenByEntity.IsDead)
            {
                RiddenByEntity = null;
            }
        }
Beispiel #9
0
        private void UpdateNumVillagers()
        {
            List <Entity> list = WorldObj.GetEntitiesWithinAABB(typeof(net.minecraft.src.EntityVillager), AxisAlignedBB.GetBoundingBoxFromPool(Center.PosX - VillageRadius, Center.PosY - 4, Center.PosZ - VillageRadius, Center.PosX + VillageRadius, Center.PosY + 4, Center.PosZ + VillageRadius));

            NumVillagers = list.Count;
        }
        /// <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);
        }
 /// <summary>
 /// Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
 /// cleared to be reused)
 /// </summary>
 public override AxisAlignedBB GetCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
 {
     return(AxisAlignedBB.GetBoundingBoxFromPool(par2 + 0, par3 + 0, par4 + 0, par2 + 1, par3 + 1, par4 + 1));
 }
Beispiel #12
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);
        }
Beispiel #13
0
        /// <summary>
        /// Update the detector rail power state if a minecart enter, stays or leave the block.
        /// </summary>
        private void SetStateIfMinecartInteractsWithRail(World par1World, int par2, int par3, int par4, int par5)
        {
            bool          flag  = (par5 & 8) != 0;
            bool          flag1 = false;
            float         f     = 0.125F;
            List <Entity> list  = par1World.GetEntitiesWithinAABB(typeof(net.minecraft.src.EntityMinecart), AxisAlignedBB.GetBoundingBoxFromPool((float)par2 + f, par3, (float)par4 + f, (float)(par2 + 1) - f, (float)(par3 + 1) - f, (float)(par4 + 1) - f));

            if (list.Count > 0)
            {
                flag1 = true;
            }

            if (flag1 && !flag)
            {
                par1World.SetBlockMetadataWithNotify(par2, par3, par4, par5 | 8);
                par1World.NotifyBlocksOfNeighborChange(par2, par3, par4, BlockID);
                par1World.NotifyBlocksOfNeighborChange(par2, par3 - 1, par4, BlockID);
                par1World.MarkBlocksDirty(par2, par3, par4, par2, par3, par4);
            }

            if (!flag1 && flag)
            {
                par1World.SetBlockMetadataWithNotify(par2, par3, par4, par5 & 7);
                par1World.NotifyBlocksOfNeighborChange(par2, par3, par4, BlockID);
                par1World.NotifyBlocksOfNeighborChange(par2, par3 - 1, par4, BlockID);
                par1World.MarkBlocksDirty(par2, par3, par4, par2, par3, par4);
            }

            if (flag1)
            {
                par1World.ScheduleBlockUpdate(par2, par3, par4, BlockID, TickRate());
            }
        }
Beispiel #14
0
        /// <summary>
        /// Execute a one shot task or start executing a continuous task
        /// </summary>
        public override void StartExecuting()
        {
            TaskOwner.SetAttackTarget(TaskOwner.GetAITarget());

            if (Field_48395_a)
            {
                List <Entity>        list     = TaskOwner.WorldObj.GetEntitiesWithinAABB(TaskOwner.GetType(), AxisAlignedBB.GetBoundingBoxFromPool(TaskOwner.PosX, TaskOwner.PosY, TaskOwner.PosZ, TaskOwner.PosX + 1, TaskOwner.PosY + 1, TaskOwner.PosZ + 1).Expand(Field_48379_d, 4, Field_48379_d));
                IEnumerator <Entity> iterator = list.GetEnumerator();

                do
                {
                    if (!iterator.MoveNext())
                    {
                        break;
                    }

                    Entity       entity       = iterator.Current;
                    EntityLiving entityliving = (EntityLiving)entity;

                    if (TaskOwner != entityliving && entityliving.GetAttackTarget() == null)
                    {
                        entityliving.SetAttackTarget(TaskOwner.GetAITarget());
                    }
                }while (true);
            }

            base.StartExecuting();
        }