/// <summary> /// Called to update the entity's position/logic. /// </summary> public override void OnUpdate() { PrevPosX = PosX; PrevPosY = PosY; PrevPosZ = PosZ; if (ParticleAge++ >= ParticleMaxAge) { SetDead(); } SetParticleTextureIndex(7 - (ParticleAge * 8) / ParticleMaxAge); MoveEntity(MotionX, MotionY, MotionZ); MotionX *= 0.95999997854232788F; MotionY *= 0.95999997854232788F; MotionZ *= 0.95999997854232788F; EntityPlayer entityplayer = WorldObj.GetClosestPlayerToEntity(this, 2); if (entityplayer != null && PosY > entityplayer.BoundingBox.MinY) { PosY += (entityplayer.BoundingBox.MinY - PosY) * 0.20000000000000001F; MotionY += (entityplayer.MotionY - MotionY) * 0.20000000000000001F; SetPosition(PosX, PosY, PosZ); } if (OnGround) { MotionX *= 0.69999998807907104F; MotionZ *= 0.69999998807907104F; } }
/// <summary> /// Checks if the entity's current position is a valid location to spawn this entity. /// </summary> public override bool GetCanSpawnHere() { if (base.GetCanSpawnHere()) { EntityPlayer entityplayer = WorldObj.GetClosestPlayerToEntity(this, 5); return(entityplayer == null); } else { return(false); } }
/// <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(); } }