Ejemplo n.º 1
0
        /// <summary>
        /// Called to update the entity's position/logic.
        /// </summary>
        public override void OnUpdate()
        {
            base.OnUpdate();

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

            PrevPosX = PosX;
            PrevPosY = PosY;
            PrevPosZ = PosZ;
            MotionY -= 0.039999999105930328F;

            if (WorldObj.GetBlockMaterial(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(PosY), MathHelper2.Floor_double(PosZ)) == Material.Lava)
            {
                MotionY = 0.20000000298023224F;
                MotionX = (Rand.NextFloat() - Rand.NextFloat()) * 0.2F;
                MotionZ = (Rand.NextFloat() - Rand.NextFloat()) * 0.2F;
                WorldObj.PlaySoundAtEntity(this, "random.fizz", 0.4F, 2.0F + Rand.NextFloat() * 0.4F);
            }

            PushOutOfBlocks(PosX, (BoundingBox.MinY + BoundingBox.MaxY) / 2F, PosZ);
            MoveEntity(MotionX, MotionY, MotionZ);
            float f = 0.98F;

            if (OnGround)
            {
                f = 0.5880001F;
                int i = WorldObj.GetBlockId(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(BoundingBox.MinY) - 1, MathHelper2.Floor_double(PosZ));

                if (i > 0)
                {
                    f = Block.BlocksList[i].Slipperiness * 0.98F;
                }
            }

            MotionX *= f;
            MotionY *= 0.98000001907348633F;
            MotionZ *= f;

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

            Age++;

            if (Age >= 6000)
            {
                SetDead();
            }
        }
		/// <summary>
		/// Called to update the entity's position/logic.
		/// </summary>
		public override void OnUpdate()
		{
			PrevPosX = PosX;
			PrevPosY = PosY;
			PrevPosZ = PosZ;
			MoveEntity(MotionX, MotionY, MotionZ);

			if (WorldObj.GetBlockMaterial(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(PosY), MathHelper2.Floor_double(PosZ)) != Material.Water)
			{
				SetDead();
			}

			if (ParticleMaxAge-- <= 0)
			{
				SetDead();
			}
		}
Ejemplo n.º 3
0
        /// <summary>
        /// Called to update the entity's position/logic.
        /// </summary>
        public override void OnUpdate()
        {
            PrevPosX = PosX;
            PrevPosY = PosY;
            PrevPosZ = PosZ;
            MotionY -= ParticleGravity;
            MoveEntity(MotionX, MotionY, MotionZ);
            MotionX *= 0.98000001907348633F;
            MotionY *= 0.98000001907348633F;
            MotionZ *= 0.98000001907348633F;

            if (ParticleMaxAge-- <= 0)
            {
                SetDead();
            }

            if (OnGround)
            {
                if ((new Random(1)).NextDouble() < 0.5D)
                {
                    SetDead();
                }

                MotionX *= 0.69999998807907104F;
                MotionZ *= 0.69999998807907104F;
            }

            Material material = WorldObj.GetBlockMaterial(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(PosY), MathHelper2.Floor_double(PosZ));

            if (material.IsLiquid() || material.IsSolid())
            {
                double d = (float)(MathHelper2.Floor_double(PosY) + 1) - BlockFluid.GetFluidHeightPercent(WorldObj.GetBlockMetadata(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(PosY), MathHelper2.Floor_double(PosZ)));

                if (PosY < d)
                {
                    SetDead();
                }
            }
        }
        /// <summary>
        /// checks to make sure painting can be placed there
        /// </summary>
        public virtual bool OnValidSurface()
        {
            if (WorldObj.GetCollidingBoundingBoxes(this, BoundingBox).Count > 0)
            {
                return(false);
            }

            int i  = Art.SizeX / 16;
            int j  = Art.SizeY / 16;
            int k  = XPosition;
            int l  = YPosition;
            int i1 = ZPosition;

            if (Direction == 0)
            {
                k = MathHelper2.Floor_double(PosX - (double)((float)Art.SizeX / 32F));
            }

            if (Direction == 1)
            {
                i1 = MathHelper2.Floor_double(PosZ - (double)((float)Art.SizeX / 32F));
            }

            if (Direction == 2)
            {
                k = MathHelper2.Floor_double(PosX - (double)((float)Art.SizeX / 32F));
            }

            if (Direction == 3)
            {
                i1 = MathHelper2.Floor_double(PosZ - (double)((float)Art.SizeX / 32F));
            }

            l = MathHelper2.Floor_double(PosY - (double)((float)Art.SizeY / 32F));

            for (int j1 = 0; j1 < i; j1++)
            {
                for (int k1 = 0; k1 < j; k1++)
                {
                    Material material;

                    if (Direction == 0 || Direction == 2)
                    {
                        material = WorldObj.GetBlockMaterial(k + j1, l + k1, ZPosition);
                    }
                    else
                    {
                        material = WorldObj.GetBlockMaterial(XPosition, l + k1, i1 + j1);
                    }

                    if (!material.IsSolid())
                    {
                        return(false);
                    }
                }
            }

            List <Entity> list = WorldObj.GetEntitiesWithinAABBExcludingEntity(this, BoundingBox);

            for (int l1 = 0; l1 < list.Count; l1++)
            {
                if (list[l1] is EntityPainting)
                {
                    return(false);
                }
            }

            return(true);
        }
        /// <summary>
        /// Called to update the entity's position/logic.
        /// </summary>
        public override void OnUpdate()
        {
            PrevPosX = PosX;
            PrevPosY = PosY;
            PrevPosZ = PosZ;

            if (MaterialType == Material.Water)
            {
                ParticleRed   = 0.2F;
                ParticleGreen = 0.3F;
                ParticleBlue  = 1.0F;
            }
            else
            {
                ParticleRed   = 1.0F;
                ParticleGreen = 16F / (float)((40 - BobTimer) + 16);
                ParticleBlue  = 4F / (float)((40 - BobTimer) + 8);
            }

            MotionY -= ParticleGravity;

            if (BobTimer-- > 0)
            {
                MotionX *= 0.02F;
                MotionY *= 0.02F;
                MotionZ *= 0.02F;
                SetParticleTextureIndex(113);
            }
            else
            {
                SetParticleTextureIndex(112);
            }

            MoveEntity(MotionX, MotionY, MotionZ);
            MotionX *= 0.98000001907348633F;
            MotionY *= 0.98000001907348633F;
            MotionZ *= 0.98000001907348633F;

            if (ParticleMaxAge-- <= 0)
            {
                SetDead();
            }

            if (OnGround)
            {
                if (MaterialType == Material.Water)
                {
                    SetDead();
                    WorldObj.SpawnParticle("splash", PosX, PosY, PosZ, 0.0F, 0.0F, 0.0F);
                }
                else
                {
                    SetParticleTextureIndex(114);
                }

                MotionX *= 0.69999998807907104F;
                MotionZ *= 0.69999998807907104F;
            }

            Material material = WorldObj.GetBlockMaterial(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(PosY), MathHelper2.Floor_double(PosZ));

            if (material.IsLiquid() || material.IsSolid())
            {
                double d = (float)(MathHelper2.Floor_double(PosY) + 1) - BlockFluid.GetFluidHeightPercent(WorldObj.GetBlockMetadata(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(PosY), MathHelper2.Floor_double(PosZ)));

                if (PosY < d)
                {
                    SetDead();
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Called to update the entity's position/logic.
        /// </summary>
        public override void OnUpdate()
        {
            base.OnUpdate();

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

            PrevPosX = PosX;
            PrevPosY = PosY;
            PrevPosZ = PosZ;
            MotionY -= 0.029999999329447746F;

            if (WorldObj.GetBlockMaterial(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(PosY), MathHelper2.Floor_double(PosZ)) == Material.Lava)
            {
                MotionY = 0.20000000298023224F;
                MotionX = (Rand.NextFloat() - Rand.NextFloat()) * 0.2F;
                MotionZ = (Rand.NextFloat() - Rand.NextFloat()) * 0.2F;
                WorldObj.PlaySoundAtEntity(this, "random.fizz", 0.4F, 2.0F + Rand.NextFloat() * 0.4F);
            }

            PushOutOfBlocks(PosX, (BoundingBox.MinY + BoundingBox.MaxY) / 2F, PosZ);
            float        d            = 8F;
            EntityPlayer entityplayer = WorldObj.GetClosestPlayerToEntity(this, d);

            if (entityplayer != null)
            {
                float d1 = (entityplayer.PosX - PosX) / d;
                float d2 = ((entityplayer.PosY + entityplayer.GetEyeHeight()) - PosY) / d;
                float d3 = (entityplayer.PosZ - PosZ) / d;
                float d4 = (float)Math.Sqrt(d1 * d1 + d2 * d2 + d3 * d3);
                float d5 = 1.0F - d4;

                if (d5 > 0.0F)
                {
                    d5      *= d5;
                    MotionX += (d1 / d4) * d5 * 0.10000000000000001F;
                    MotionY += (d2 / d4) * d5 * 0.10000000000000001F;
                    MotionZ += (d3 / d4) * d5 * 0.10000000000000001F;
                }
            }

            MoveEntity(MotionX, MotionY, MotionZ);
            float f = 0.98F;

            if (OnGround)
            {
                f = 0.5880001F;
                int i = WorldObj.GetBlockId(MathHelper2.Floor_double(PosX), MathHelper2.Floor_double(BoundingBox.MinY) - 1, MathHelper2.Floor_double(PosZ));

                if (i > 0)
                {
                    f = Block.BlocksList[i].Slipperiness * 0.98F;
                }
            }

            MotionX *= f;
            MotionY *= 0.98000001907348633F;
            MotionZ *= f;

            if (OnGround)
            {
                MotionY *= -0.89999997615814209F;
            }

            XpColor++;
            XpOrbAge++;

            if (XpOrbAge >= 6000)
            {
                SetDead();
            }
        }