/// <summary> /// Called to update the entity's position/logic. /// </summary> public override void OnUpdate() { if (!WorldObj.BlockExists(MathHelper2.Floor_double(PosX), 0, MathHelper2.Floor_double(PosZ))) { return; } else { base.OnUpdate(); SendMotionUpdates(); return; } }
/// <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); }
/// <summary> /// Teleport the enderman /// </summary> protected virtual bool TeleportTo(float par1, float par3, float par5) { float d = PosX; float d1 = PosY; float d2 = PosZ; PosX = par1; PosY = par3; PosZ = par5; bool flag = false; int i = MathHelper2.Floor_double(PosX); int j = MathHelper2.Floor_double(PosY); int k = MathHelper2.Floor_double(PosZ); if (WorldObj.BlockExists(i, j, k)) { bool flag1; for (flag1 = false; !flag1 && j > 0;) { int i1 = WorldObj.GetBlockId(i, j - 1, k); if (i1 == 0 || !Block.BlocksList[i1].BlockMaterial.BlocksMovement()) { PosY--; j--; } else { flag1 = true; } } if (flag1) { SetPosition(PosX, PosY, PosZ); if (WorldObj.GetCollidingBoundingBoxes(this, BoundingBox).Count == 0 && !WorldObj.IsAnyLiquid(BoundingBox)) { flag = true; } } } if (!flag) { SetPosition(d, d1, d2); return(false); } int l = 128; for (int j1 = 0; j1 < l; j1++) { double d3 = (double)j1 / ((double)l - 1.0D); float f = (Rand.NextFloat() - 0.5F) * 0.2F; float f1 = (Rand.NextFloat() - 0.5F) * 0.2F; float f2 = (Rand.NextFloat() - 0.5F) * 0.2F; double d4 = d + (PosX - d) * d3 + (Rand.NextDouble() - 0.5D) * (double)Width * 2D; double d5 = d1 + (PosY - d1) * d3 + Rand.NextDouble() * (double)Height; double d6 = d2 + (PosZ - d2) * d3 + (Rand.NextDouble() - 0.5D) * (double)Width * 2D; WorldObj.SpawnParticle("portal", d4, d5, d6, f, f1, f2); } WorldObj.PlaySoundEffect(d, d1, d2, "mob.endermen.portal", 1.0F, 1.0F); WorldObj.PlaySoundAtEntity(this, "mob.endermen.portal", 1.0F, 1.0F); return(true); }