/// <summary> /// Returns the block ID at the current camera location (either air or fluid), taking into account the height of /// fluid blocks /// </summary> public static int GetBlockIdAtEntityViewpoint(World par0World, EntityLiving par1EntityLiving, float par2) { Vec3D vec3d = ProjectViewFromEntity(par1EntityLiving, par2); ChunkPosition chunkposition = new ChunkPosition(vec3d); int i = par0World.GetBlockId(chunkposition.x, chunkposition.y, chunkposition.z); if (i != 0 && Block.BlocksList[i].BlockMaterial.IsLiquid()) { float f = BlockFluid.GetFluidHeightPercent(par0World.GetBlockMetadata(chunkposition.x, chunkposition.y, chunkposition.z)) - 0.1111111F; float f1 = (float)(chunkposition.y + 1) - f; if (vec3d.YCoord >= (double)f1) { i = par0World.GetBlockId(chunkposition.x, chunkposition.y + 1, chunkposition.z); } } return(i); }
/// <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> /// 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(); } } }