/// <summary> /// Called to update the entity's position/logic. /// </summary> public override void OnUpdate() { Field_22062_y = 0.0F; base.OnUpdate(); Field_705_Q = Field_704_R; double d = PosX - PrevPosX; double d1 = PosZ - PrevPosZ; float f = MathHelper2.Sqrt_double(d * d + d1 * d1) * 4F; if (f > 1.0F) { f = 1.0F; } Field_704_R += (f - Field_704_R) * 0.4F; Field_703_S += Field_704_R; if (!IsItemInUse && IsEating() && Inventory.MainInventory[Inventory.CurrentItem] != null) { ItemStack itemstack = Inventory.MainInventory[Inventory.CurrentItem]; SetItemInUse(Inventory.MainInventory[Inventory.CurrentItem], Item.ItemsList[itemstack.ItemID].GetMaxItemUseDuration(itemstack)); IsItemInUse = true; } else if (IsItemInUse && !IsEating()) { ClearItemInUse(); IsItemInUse = false; } }
/// <summary> /// Basic mob attack. Default to touch of death in EntityCreature. Overridden by each mob to define their attack. /// </summary> protected override void AttackEntity(Entity par1Entity, float par2) { float f = GetBrightness(1.0F); if (f > 0.5F && Rand.Next(100) == 0) { EntityToAttack = null; return; } if (par2 > 2.0F && par2 < 6F && Rand.Next(10) == 0) { if (OnGround) { float d = par1Entity.PosX - PosX; float d1 = par1Entity.PosZ - PosZ; float f1 = MathHelper2.Sqrt_double(d * d + d1 * d1); MotionX = (d / f1) * 0.5F * 0.80000001192092896F + MotionX * 0.20000000298023224F; MotionZ = (d1 / f1) * 0.5F * 0.80000001192092896F + MotionZ * 0.20000000298023224F; MotionY = 0.40000000596046448F; } } else { base.AttackEntity(par1Entity, par2); } }
/// <summary> /// Euclidean distance between this and the specified vector, returned as double. /// </summary> public virtual double DistanceTo(Vec3D par1Vec3D) { double d = par1Vec3D.XCoord - XCoord; double d1 = par1Vec3D.YCoord - YCoord; double d2 = par1Vec3D.ZCoord - ZCoord; return((double)MathHelper2.Sqrt_double(d * d + d1 * d1 + d2 * d2)); }
/// <summary> /// Sets the velocity to the args. Args: x, y, z /// </summary> public override void SetVelocity(float par1, float par3, float par5) { MotionX = par1; MotionY = par3; MotionZ = par5; if (PrevRotationPitch == 0.0F && PrevRotationYaw == 0.0F) { float f = MathHelper2.Sqrt_double(par1 * par1 + par5 * par5); PrevRotationYaw = RotationYaw = (float)((Math.Atan2(par1, par5) * 180D) / Math.PI); PrevRotationPitch = RotationPitch = (float)((Math.Atan2(par3, f) * 180D) / Math.PI); } }
/// <summary> /// Normalizes the vector to a length of 1 (except if it is the zero vector) /// </summary> public virtual Vec3D Normalize() { double d = MathHelper2.Sqrt_double(XCoord * XCoord + YCoord * YCoord + ZCoord * ZCoord); if (d < 0.0001D) { return(CreateVector(0.0F, 0.0F, 0.0F)); } else { return(CreateVector(XCoord / d, YCoord / d, ZCoord / d)); } }
/// <summary> /// Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons /// use this to react to sunlight and start to burn. /// </summary> public override void OnLivingUpdate() { base.UpdateEntityActionState(); if (OtherPlayerMPPosRotationIncrements > 0) { float d = PosX + (OtherPlayerMPX - PosX) / OtherPlayerMPPosRotationIncrements; float d1 = PosY + (OtherPlayerMPY - PosY) / OtherPlayerMPPosRotationIncrements; float d2 = PosZ + (OtherPlayerMPZ - PosZ) / OtherPlayerMPPosRotationIncrements; double d3; for (d3 = OtherPlayerMPYaw - RotationYaw; d3 < -180D; d3 += 360D) { } for (; d3 >= 180D; d3 -= 360D) { } RotationYaw += (float)d3 / OtherPlayerMPPosRotationIncrements; RotationPitch += (float)(OtherPlayerMPPitch - RotationPitch) / OtherPlayerMPPosRotationIncrements; OtherPlayerMPPosRotationIncrements--; SetPosition(d, d1, d2); SetRotation(RotationYaw, RotationPitch); } PrevCameraYaw = CameraYaw; float f = MathHelper2.Sqrt_double(MotionX * MotionX + MotionZ * MotionZ); float f1 = (float)Math.Atan(-MotionY * 0.20000000298023224D) * 15F; if (f > 0.1F) { f = 0.1F; } if (!OnGround || GetHealth() <= 0) { f = 0.0F; } if (OnGround || GetHealth() <= 0) { f1 = 0.0F; } CameraYaw += (f - CameraYaw) * 0.4F; CameraPitch += (f1 - CameraPitch) * 0.8F; }
/// <summary> /// Sets the velocity to the args. Args: x, y, z /// </summary> public override void SetVelocity(float par1, float par3, float par5) { MotionX = par1; MotionY = par3; MotionZ = par5; if (PrevRotationPitch == 0.0F && PrevRotationYaw == 0.0F) { float f = MathHelper2.Sqrt_double(par1 * par1 + par5 * par5); PrevRotationYaw = RotationYaw = (float)((Math.Atan2(par1, par5) * 180D) / Math.PI); PrevRotationPitch = RotationPitch = (float)((Math.Atan2(par3, f) * 180D) / Math.PI); PrevRotationPitch = RotationPitch; PrevRotationYaw = RotationYaw; SetLocationAndAngles(PosX, PosY, PosZ, RotationYaw, RotationPitch); TicksInGround = 0; } }
public EntityFireball(World par1World, float par2, float par4, float par6, float par8, float par10, float par12) : base(par1World) { XTile = -1; YTile = -1; ZTile = -1; InTile = 0; InGround = false; TicksInAir = 0; SetSize(1.0F, 1.0F); SetLocationAndAngles(par2, par4, par6, RotationYaw, RotationPitch); SetPosition(par2, par4, par6); float d = MathHelper2.Sqrt_double(par8 * par8 + par10 * par10 + par12 * par12); AccelerationX = (par8 / d) * 0.10000000000000001F; AccelerationY = (par10 / d) * 0.10000000000000001F; AccelerationZ = (par12 / d) * 0.10000000000000001F; }
/// <summary> /// Updates look /// </summary> public virtual void OnUpdateLook() { Entity.RotationPitch = 0.0F; if (Field_46147_d) { Field_46147_d = false; double d = PosX - Entity.PosX; double d1 = PosY - (Entity.PosY + (double)Entity.GetEyeHeight()); double d2 = PosZ - Entity.PosZ; double d3 = MathHelper2.Sqrt_double(d * d + d2 * d2); float f1 = (float)((Math.Atan2(d2, d) * 180D) / Math.PI) - 90F; float f2 = (float)(-((Math.Atan2(d1, d3) * 180D) / Math.PI)); Entity.RotationPitch = UpdateRotation(Entity.RotationPitch, f2, Field_46150_c); Entity.RotationYawHead = UpdateRotation(Entity.RotationYawHead, f1, Field_46149_b); } else { Entity.RotationYawHead = UpdateRotation(Entity.RotationYawHead, Entity.RenderYawOffset, 10F); } float f; for (f = Entity.RotationYawHead - Entity.RenderYawOffset; f < -180F; f += 360F) { } for (; f >= 180F; f -= 360F) { } if (!Entity.GetNavigator().NoPath()) { if (f < -75F) { Entity.RotationYawHead = Entity.RenderYawOffset - 75F; } if (f > 75F) { Entity.RotationYawHead = Entity.RenderYawOffset + 75F; } } }
/// <summary> /// Performs a ranged attack according to the AI's rangedAttackID. /// </summary> private void DoRangedAttack() { if (RangedAttackID == 1) { EntityArrow entityarrow = new EntityArrow(WorldObj, EntityHost, AttackTarget, 1.6F, 12F); WorldObj.PlaySoundAtEntity(EntityHost, "random.bow", 1.0F, 1.0F / (EntityHost.GetRNG().NextFloat() * 0.4F + 0.8F)); WorldObj.SpawnEntityInWorld(entityarrow); } else if (RangedAttackID == 2) { EntitySnowball entitysnowball = new EntitySnowball(WorldObj, EntityHost); float d = AttackTarget.PosX - EntityHost.PosX; float d1 = (AttackTarget.PosY + AttackTarget.GetEyeHeight()) - 1.1000000238418579F - entitysnowball.PosY; float d2 = AttackTarget.PosZ - EntityHost.PosZ; float f = MathHelper2.Sqrt_double(d * d + d2 * d2) * 0.2F; entitysnowball.SetThrowableHeading(d, d1 + f, d2, 1.6F, 12F); WorldObj.PlaySoundAtEntity(EntityHost, "random.bow", 1.0F, 1.0F / (EntityHost.GetRNG().NextFloat() * 0.4F + 0.8F)); WorldObj.SpawnEntityInWorld(entitysnowball); } }
public virtual int CatchFish() { byte byte0 = 0; if (Bobber != null) { float d = Angler.PosX - PosX; float d2 = Angler.PosY - PosY; float d4 = Angler.PosZ - PosZ; double d6 = MathHelper2.Sqrt_double(d * d + d2 * d2 + d4 * d4); float d8 = 0.10000000000000001F; Bobber.MotionX += d * d8; Bobber.MotionY += d2 * d8 + MathHelper2.Sqrt_double(d6) * 0.080000000000000002F; Bobber.MotionZ += d4 * d8; byte0 = 3; } else if (TicksCatchable > 0) { EntityItem entityitem = new EntityItem(WorldObj, PosX, PosY, PosZ, new ItemStack(Item.FishRaw)); float d1 = Angler.PosX - PosX; float d3 = Angler.PosY - PosY; float d5 = Angler.PosZ - PosZ; double d7 = MathHelper2.Sqrt_double(d1 * d1 + d3 * d3 + d5 * d5); float d9 = 0.10000000000000001F; entityitem.MotionX = d1 * d9; entityitem.MotionY = d3 * d9 + MathHelper2.Sqrt_double(d7) * 0.080000000000000002F; entityitem.MotionZ = d5 * d9; WorldObj.SpawnEntityInWorld(entityitem); Angler.AddStat(StatList.FishCaughtStat, 1); byte0 = 1; } if (InGround) { byte0 = 2; } SetDead(); Angler.FishEntity = null; return(byte0); }
/// <summary> /// Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. /// </summary> public virtual void SetThrowableHeading(float par1, float par3, float par5, float par7, float par8) { float f = MathHelper2.Sqrt_double(par1 * par1 + par3 * par3 + par5 * par5); par1 /= f; par3 /= f; par5 /= f; par1 += Rand.NextGaussian() * 0.0074999998323619366F * par8; par3 += Rand.NextGaussian() * 0.0074999998323619366F * par8; par5 += Rand.NextGaussian() * 0.0074999998323619366F * par8; par1 *= par7; par3 *= par7; par5 *= par7; MotionX = par1; MotionY = par3; MotionZ = par5; float f1 = MathHelper2.Sqrt_double(par1 * par1 + par5 * par5); PrevRotationYaw = RotationYaw = (float)((Math.Atan2(par1, par5) * 180D) / Math.PI); PrevRotationPitch = RotationPitch = (float)((Math.Atan2(par3, f1) * 180D) / Math.PI); TicksInGround = 0; }
public EntityArrow(World par1World, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving, float par4, float par5) : base(par1World) { XTile = -1; YTile = -1; ZTile = -1; InTile = 0; InData = 0; InGround = false; DoesArrowBelongToPlayer = false; ArrowShake = 0; TicksInAir = 0; Damage = 2D; ArrowCritical = false; ShootingEntity = par2EntityLiving; DoesArrowBelongToPlayer = par2EntityLiving is EntityPlayer; PosY = (par2EntityLiving.PosY + par2EntityLiving.GetEyeHeight()) - 0.10000000149011612F; float d = par3EntityLiving.PosX - par2EntityLiving.PosX; float d1 = (par3EntityLiving.PosY + par3EntityLiving.GetEyeHeight()) - 0.69999998807907104F - PosY; float d2 = par3EntityLiving.PosZ - par2EntityLiving.PosZ; float d3 = MathHelper2.Sqrt_double(d * d + d2 * d2); //JAVA TO C# CONVERTER TODO TASK: Octal literals cannot be represented in C#: if (d3 < 9.9999999999999995E-008D) { return; } else { float f = (float)((Math.Atan2(d2, d) * 180D) / Math.PI) - 90F; float f1 = (float)(-((Math.Atan2(d1, d3) * 180D) / Math.PI)); float d4 = d / d3; float d5 = d2 / d3; SetLocationAndAngles(par2EntityLiving.PosX + d4, PosY, par2EntityLiving.PosZ + d5, f, f1); YOffset = 0.0F; float f2 = (float)d3 * 0.2F; SetArrowHeading(d, d1 + f2, d2, par4, par5); return; } }
public virtual void Func_40090_a(double par1, int par3, double par4) { double d = par1 - PosX; double d1 = par4 - PosZ; float f = MathHelper2.Sqrt_double(d * d + d1 * d1); if (f > 12F) { Field_40094_b = PosX + (d / (double)f) * 12D; Field_40091_d = PosZ + (d1 / (double)f) * 12D; Field_40095_c = PosY + 8D; } else { Field_40094_b = par1; Field_40095_c = par3; Field_40091_d = par4; } DespawnTimer = 0; ShatterOrDrop = Rand.Next(5) > 0; }
public EntityFX(World par1World, float par2, float par4, float par6, float par8, float par10, float par12) : base(par1World) { ParticleAge = 0; ParticleMaxAge = 0; SetSize(0.2F, 0.2F); YOffset = Height / 2.0F; SetPosition(par2, par4, par6); ParticleRed = ParticleGreen = ParticleBlue = 1.0F; MotionX = par8 + ((new Random(1).NextFloat() * 2 - 1.0F) * 0.4F); MotionY = par10 + ((new Random(2).NextFloat() * 2 - 1.0F) * 0.4F); MotionZ = par12 + ((new Random(3).NextFloat() * 2 - 1.0F) * 0.4F); float f = (new Random(4).NextFloat() + new Random(5).NextFloat() + 1.0F) * 0.15F; float f1 = MathHelper2.Sqrt_double(MotionX * MotionX + MotionY * MotionY + MotionZ * MotionZ); MotionX = (MotionX / f1) * f * 0.40000000596046448F; MotionY = (MotionY / f1) * f * 0.40000000596046448F + 0.10000000149011612F; MotionZ = (MotionZ / f1) * f * 0.40000000596046448F; ParticleTextureJitterX = Rand.NextFloat() * 3F; ParticleTextureJitterY = Rand.NextFloat() * 3F; ParticleScale = (Rand.NextFloat() * 0.5F + 0.5F) * 2.0F; ParticleMaxAge = (int)(4F / (Rand.NextFloat() * 0.9F + 0.1F)); ParticleAge = 0; }
public EntityFireball(World par1World, EntityLiving par2EntityLiving, float par3, float par5, float par7) : base(par1World) { XTile = -1; YTile = -1; ZTile = -1; InTile = 0; InGround = false; TicksInAir = 0; ShootingEntity = par2EntityLiving; SetSize(1.0F, 1.0F); SetLocationAndAngles(par2EntityLiving.PosX, par2EntityLiving.PosY, par2EntityLiving.PosZ, par2EntityLiving.RotationYaw, par2EntityLiving.RotationPitch); SetPosition(PosX, PosY, PosZ); YOffset = 0.0F; MotionX = MotionY = MotionZ = 0.0F; par3 += Rand.NextGaussian() * 0.40000000000000002F; par5 += Rand.NextGaussian() * 0.40000000000000002F; par7 += Rand.NextGaussian() * 0.40000000000000002F; float d = MathHelper2.Sqrt_double(par3 * par3 + par5 * par5 + par7 * par7); AccelerationX = (par3 / d) * 0.10000000000000001F; AccelerationY = (par5 / d) * 0.10000000000000001F; AccelerationZ = (par7 / d) * 0.10000000000000001F; }
/// <summary> /// Called to update the entity's position/logic. /// </summary> public override void OnUpdate() { LastTickPosX = PosX; LastTickPosY = PosY; LastTickPosZ = PosZ; base.OnUpdate(); if (ThrowableShake > 0) { ThrowableShake--; } 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); } if (!WorldObj.IsRemote) { Entity entity = null; List <Entity> list = WorldObj.GetEntitiesWithinAABBExcludingEntity(this, BoundingBox.AddCoord(MotionX, MotionY, MotionZ).Expand(1.0F, 1.0F, 1.0F)); float d = 0.0F; for (int k = 0; k < list.Count; k++) { Entity entity1 = list[k]; if (!entity1.CanBeCollidedWith() || entity1 == Thrower && TicksInAir < 5) { continue; } float f4 = 0.3F; AxisAlignedBB axisalignedbb = entity1.BoundingBox.Expand(f4, f4, f4); MovingObjectPosition movingobjectposition1 = axisalignedbb.CalculateIntercept(vec3d, vec3d1); if (movingobjectposition1 == null) { continue; } float d1 = (float)vec3d.DistanceTo(movingobjectposition1.HitVec); if (d1 < d || d == 0.0F) { entity = entity1; d = d1; } } if (entity != null) { movingobjectposition = new MovingObjectPosition(entity); } } if (movingobjectposition != null) { OnImpact(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.99F; float f2 = Func_40075_e(); if (IsInWater()) { for (int j = 0; j < 4; j++) { float f3 = 0.25F; WorldObj.SpawnParticle("bubble", PosX - MotionX * f3, PosY - MotionY * f3, PosZ - MotionZ * f3, MotionX, MotionY, MotionZ); } f1 = 0.8F; } MotionX *= f1; MotionY *= f1; MotionZ *= f1; MotionY -= f2; SetPosition(PosX, PosY, PosZ); }
/// <summary> /// Applies a velocity to each of the entities pushing them away from each other. Args: entity /// </summary> public override void ApplyEntityCollision(Entity par1Entity) { if (WorldObj.IsRemote) { return; } if (par1Entity == RiddenByEntity) { return; } if ((par1Entity is EntityLiving) && !(par1Entity is EntityPlayer) && !(par1Entity is EntityIronGolem) && MinecartType == 0 && MotionX * MotionX + MotionZ * MotionZ > 0.01D && RiddenByEntity == null && par1Entity.RidingEntity == null) { par1Entity.MountEntity(this); } float d = par1Entity.PosX - PosX; float d1 = par1Entity.PosZ - PosZ; float d2 = d * d + d1 * d1; //JAVA TO C# CONVERTER TODO TASK: Octal literals cannot be represented in C#: if (d2 >= 9.9999997473787516E-005D) { d2 = MathHelper2.Sqrt_double(d2); d /= d2; d1 /= d2; float d3 = 1.0F / d2; if (d3 > 1.0F) { d3 = 1.0F; } d *= d3; d1 *= d3; d *= 0.10000000149011612F; d1 *= 0.10000000149011612F; d *= 1.0F - EntityCollisionReduction; d1 *= 1.0F - EntityCollisionReduction; d *= 0.5F; d1 *= 0.5F; if (par1Entity is EntityMinecart) { double d4 = par1Entity.PosX - PosX; double d5 = par1Entity.PosZ - PosZ; Vec3D vec3d = Vec3D.CreateVector(d4, 0.0F, d5).Normalize(); Vec3D vec3d1 = Vec3D.CreateVector(MathHelper2.Cos((RotationYaw * (float)Math.PI) / 180F), 0.0F, MathHelper2.Sin((RotationYaw * (float)Math.PI) / 180F)).Normalize(); double d6 = Math.Abs(vec3d.DotProduct(vec3d1)); if (d6 < 0.80000001192092896D) { return; } float d7 = par1Entity.MotionX + MotionX; float d8 = par1Entity.MotionZ + MotionZ; if (((EntityMinecart)par1Entity).MinecartType == 2 && MinecartType != 2) { MotionX *= 0.20000000298023224F; MotionZ *= 0.20000000298023224F; AddVelocity(par1Entity.MotionX - d, 0.0F, par1Entity.MotionZ - d1); par1Entity.MotionX *= 0.94999998807907104F; par1Entity.MotionZ *= 0.94999998807907104F; } else if (((EntityMinecart)par1Entity).MinecartType != 2 && MinecartType == 2) { par1Entity.MotionX *= 0.20000000298023224F; par1Entity.MotionZ *= 0.20000000298023224F; par1Entity.AddVelocity(MotionX + d, 0.0F, MotionZ + d1); MotionX *= 0.94999998807907104F; MotionZ *= 0.94999998807907104F; } else { d7 /= 2F; d8 /= 2F; MotionX *= 0.20000000298023224F; MotionZ *= 0.20000000298023224F; AddVelocity(d7 - d, 0.0F, d8 - d1); par1Entity.MotionX *= 0.20000000298023224F; par1Entity.MotionZ *= 0.20000000298023224F; par1Entity.AddVelocity(d7 + d, 0.0F, d8 + d1); } } else { AddVelocity(-d, 0.0F, -d1); par1Entity.AddVelocity(d / 4F, 0.0F, d1 / 4F); } } }
/// <summary> /// Called to update the entity's position/logic. /// </summary> public override void OnUpdate() { if (Func_41023_l() > 0) { Func_41028_c(Func_41023_l() - 1); } if (Func_41025_i() > 0) { Func_41024_b(Func_41025_i() - 1); } if (PosY < -64D) { Kill(); } if (IsMinecartPowered() && Rand.Next(4) == 0) { WorldObj.SpawnParticle("largesmoke", PosX, PosY + 0.80000000000000004D, PosZ, 0.0F, 0.0F, 0.0F); } if (WorldObj.IsRemote) { if (TurnProgress > 0) { float d = PosX + (MinecartX - PosX) / TurnProgress; float d1 = PosY + (MinecartY - PosY) / TurnProgress; float d3 = PosZ + (MinecartZ - PosZ) / TurnProgress; double d5; for (d5 = MinecartYaw - RotationYaw; d5 < -180D; d5 += 360D) { } for (; d5 >= 180D; d5 -= 360D) { } RotationYaw += (float)d5 / TurnProgress; RotationPitch += ((float)MinecartPitch - RotationPitch) / TurnProgress; TurnProgress--; SetPosition(d, d1, d3); SetRotation(RotationYaw, RotationPitch); } else { SetPosition(PosX, PosY, PosZ); SetRotation(RotationYaw, RotationPitch); } return; } PrevPosX = PosX; PrevPosY = PosY; PrevPosZ = PosZ; MotionY -= 0.039999999105930328F; int i = MathHelper2.Floor_double(PosX); int j = MathHelper2.Floor_double(PosY); int k = MathHelper2.Floor_double(PosZ); if (BlockRail.IsRailBlockAt(WorldObj, i, j - 1, k)) { j--; } float d2 = 0.40000000000000002F; float d4 = 0.0078125F; int l = WorldObj.GetBlockId(i, j, k); if (BlockRail.IsRailBlock(l)) { Vec3D vec3d = Func_514_g(PosX, PosY, PosZ); int i1 = WorldObj.GetBlockMetadata(i, j, k); PosY = j; bool flag = false; bool flag1 = false; if (l == Block.RailPowered.BlockID) { flag = (i1 & 8) != 0; flag1 = !flag; } if (((BlockRail)Block.BlocksList[l]).IsPowered()) { i1 &= 7; } if (i1 >= 2 && i1 <= 5) { PosY = j + 1; } if (i1 == 2) { MotionX -= d4; } if (i1 == 3) { MotionX += d4; } if (i1 == 4) { MotionZ += d4; } if (i1 == 5) { MotionZ -= d4; } int[][] ai = Field_855_j[i1]; float d9 = ai[1][0] - ai[0][0]; float d10 = ai[1][2] - ai[0][2]; float d11 = (float)Math.Sqrt(d9 * d9 + d10 * d10); double d12 = MotionX * d9 + MotionZ * d10; if (d12 < 0.0F) { d9 = -d9; d10 = -d10; } float d13 = (float)Math.Sqrt(MotionX * MotionX + MotionZ * MotionZ); MotionX = (d13 * d9) / d11; MotionZ = (d13 * d10) / d11; if (flag1) { double d16 = Math.Sqrt(MotionX * MotionX + MotionZ * MotionZ); if (d16 < 0.029999999999999999D) { MotionX *= 0.0F; MotionY *= 0.0F; MotionZ *= 0.0F; } else { MotionX *= 0.5F; MotionY *= 0.0F; MotionZ *= 0.5F; } } float d17 = 0.0F; float d18 = i + 0.5F + ai[0][0] * 0.5F; float d19 = k + 0.5F + ai[0][2] * 0.5F; float d20 = i + 0.5F + ai[1][0] * 0.5F; float d21 = k + 0.5F + ai[1][2] * 0.5F; d9 = d20 - d18; d10 = d21 - d19; if (d9 == 0.0F) { PosX = i + 0.5F; d17 = PosZ - k; } else if (d10 == 0.0F) { PosZ = k + 0.5F; d17 = PosX - i; } else { float d22 = PosX - d18; float d24 = PosZ - d19; float d26 = (d22 * d9 + d24 * d10) * 2F; d17 = d26; } PosX = d18 + d9 * d17; PosZ = d19 + d10 * d17; SetPosition(PosX, PosY + YOffset, PosZ); float d23 = MotionX; float d25 = MotionZ; if (RiddenByEntity != null) { d23 *= 0.75F; d25 *= 0.75F; } if (d23 < -d2) { d23 = -d2; } if (d23 > d2) { d23 = d2; } if (d25 < -d2) { d25 = -d2; } if (d25 > d2) { d25 = d2; } MoveEntity(d23, 0.0F, d25); if (ai[0][1] != 0 && MathHelper2.Floor_double(PosX) - i == ai[0][0] && MathHelper2.Floor_double(PosZ) - k == ai[0][2]) { SetPosition(PosX, PosY + ai[0][1], PosZ); } else if (ai[1][1] != 0 && MathHelper2.Floor_double(PosX) - i == ai[1][0] && MathHelper2.Floor_double(PosZ) - k == ai[1][2]) { SetPosition(PosX, PosY + ai[1][1], PosZ); } if (RiddenByEntity != null) { MotionX *= 0.99699997901916504F; MotionY *= 0.0F; MotionZ *= 0.99699997901916504F; } else { if (MinecartType == 2) { float d27 = MathHelper2.Sqrt_double(PushX * PushX + PushZ * PushZ); if (d27 > 0.01D) { PushX /= d27; PushZ /= d27; float d29 = 0.040000000000000001F; MotionX *= 0.80000001192092896F; MotionY *= 0.0F; MotionZ *= 0.80000001192092896F; MotionX += PushX * d29; MotionZ += PushZ * d29; } else { MotionX *= 0.89999997615814209F; MotionY *= 0.0F; MotionZ *= 0.89999997615814209F; } } MotionX *= 0.95999997854232788F; MotionY *= 0.0F; MotionZ *= 0.95999997854232788F; } Vec3D vec3d1 = Func_514_g(PosX, PosY, PosZ); if (vec3d1 != null && vec3d != null) { float d28 = ((float)vec3d.YCoord - (float)vec3d1.YCoord) * 0.050000000000000003F; float d14 = (float)Math.Sqrt(MotionX * MotionX + MotionZ * MotionZ); if (d14 > 0.0F) { MotionX = (MotionX / d14) * (d14 + d28); MotionZ = (MotionZ / d14) * (d14 + d28); } SetPosition(PosX, (float)vec3d1.YCoord, PosZ); } int k1 = MathHelper2.Floor_double(PosX); int l1 = MathHelper2.Floor_double(PosZ); if (k1 != i || l1 != k) { float d15 = (float)Math.Sqrt(MotionX * MotionX + MotionZ * MotionZ); MotionX = d15 * (k1 - i); MotionZ = d15 * (l1 - k); } if (MinecartType == 2) { float d30 = MathHelper2.Sqrt_double(PushX * PushX + PushZ * PushZ); if (d30 > 0.01F && MotionX * MotionX + MotionZ * MotionZ > 0.001F) { PushX /= d30; PushZ /= d30; if (PushX * MotionX + PushZ * MotionZ < 0.0F) { PushX = 0.0F; PushZ = 0.0F; } else { PushX = MotionX; PushZ = MotionZ; } } } if (flag) { float d31 = (float)Math.Sqrt(MotionX * MotionX + MotionZ * MotionZ); if (d31 > 0.01D) { float d32 = 0.059999999999999998F; MotionX += (MotionX / d31) * d32; MotionZ += (MotionZ / d31) * d32; } else if (i1 == 1) { if (WorldObj.IsBlockNormalCube(i - 1, j, k)) { MotionX = 0.02F; } else if (WorldObj.IsBlockNormalCube(i + 1, j, k)) { MotionX = -0.02F; } } else if (i1 == 0) { if (WorldObj.IsBlockNormalCube(i, j, k - 1)) { MotionZ = 0.02F; } else if (WorldObj.IsBlockNormalCube(i, j, k + 1)) { MotionZ = -0.02F; } } } } else { if (MotionX < -d2) { MotionX = -d2; } if (MotionX > d2) { MotionX = d2; } if (MotionZ < -d2) { MotionZ = -d2; } if (MotionZ > d2) { MotionZ = d2; } if (OnGround) { MotionX *= 0.5F; MotionY *= 0.5F; MotionZ *= 0.5F; } MoveEntity(MotionX, MotionY, MotionZ); if (!OnGround) { MotionX *= 0.94999998807907104F; MotionY *= 0.94999998807907104F; MotionZ *= 0.94999998807907104F; } } RotationPitch = 0.0F; float d6 = PrevPosX - PosX; float d7 = PrevPosZ - PosZ; if (d6 * d6 + d7 * d7 > 0.001F) { RotationYaw = (float)((Math.Atan2(d7, d6) * 180F) / Math.PI); if (Field_856_i) { RotationYaw += 180F; } } float d8; for (d8 = RotationYaw - PrevRotationYaw; d8 >= 180F; d8 -= 360F) { } for (; d8 < -180D; d8 += 360F) { } if (d8 < -170D || d8 >= 170D) { RotationYaw += 180F; Field_856_i = !Field_856_i; } 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 = list[j1]; if (entity != RiddenByEntity && entity.CanBePushed() && (entity is EntityMinecart)) { entity.ApplyEntityCollision(this); } } } if (RiddenByEntity != null && RiddenByEntity.IsDead) { if (RiddenByEntity.RidingEntity == this) { RiddenByEntity.RidingEntity = null; } RiddenByEntity = null; } if (Fuel > 0) { Fuel--; } if (Fuel <= 0) { PushX = PushZ = 0.0F; } SetMinecartPowered(Fuel > 0); }
/// <summary> /// Returns the length of the vector. /// </summary> public virtual double LengthVector() { return((double)MathHelper2.Sqrt_double(XCoord * XCoord + YCoord * YCoord + ZCoord * ZCoord)); }
/// <summary> /// Creates the ender portal leading back to the normal world after defeating the enderdragon. /// </summary> private void CreateEnderPortal(int par1, int par2) { sbyte byte0 = 64; BlockEndPortal.BossDefeated = true; int i = 4; for (int j = byte0 - 1; j <= byte0 + 32; j++) { for (int k = par1 - i; k <= par1 + i; k++) { for (int l = par2 - i; l <= par2 + i; l++) { double d = k - par1; double d1 = l - par2; double d2 = MathHelper2.Sqrt_double(d * d + d1 * d1); if (d2 > (double)i - 0.5D) { continue; } if (j < byte0) { if (d2 <= (double)(i - 1) - 0.5D) { WorldObj.SetBlockWithNotify(k, j, l, Block.Bedrock.BlockID); } continue; } if (j > byte0) { WorldObj.SetBlockWithNotify(k, j, l, 0); continue; } if (d2 > (double)(i - 1) - 0.5D) { WorldObj.SetBlockWithNotify(k, j, l, Block.Bedrock.BlockID); } else { WorldObj.SetBlockWithNotify(k, j, l, Block.EndPortal.BlockID); } } } } WorldObj.SetBlockWithNotify(par1, byte0 + 0, par2, Block.Bedrock.BlockID); WorldObj.SetBlockWithNotify(par1, byte0 + 1, par2, Block.Bedrock.BlockID); WorldObj.SetBlockWithNotify(par1, byte0 + 2, par2, Block.Bedrock.BlockID); WorldObj.SetBlockWithNotify(par1 - 1, byte0 + 2, par2, Block.TorchWood.BlockID); WorldObj.SetBlockWithNotify(par1 + 1, byte0 + 2, par2, Block.TorchWood.BlockID); WorldObj.SetBlockWithNotify(par1, byte0 + 2, par2 - 1, Block.TorchWood.BlockID); WorldObj.SetBlockWithNotify(par1, byte0 + 2, par2 + 1, Block.TorchWood.BlockID); WorldObj.SetBlockWithNotify(par1, byte0 + 3, par2, Block.Bedrock.BlockID); WorldObj.SetBlockWithNotify(par1, byte0 + 4, par2, Block.DragonEgg.BlockID); BlockEndPortal.BossDefeated = false; }
/// <summary> /// Called to update the entity's position/logic. /// </summary> public override void OnUpdate() { LastTickPosX = PosX; LastTickPosY = PosY; LastTickPosZ = PosZ; base.OnUpdate(); 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; if (!WorldObj.IsRemote) { double d = Field_40094_b - PosX; double d1 = Field_40091_d - PosZ; float f2 = (float)Math.Sqrt(d * d + d1 * d1); float f3 = (float)Math.Atan2(d1, d); float d2 = f + (f2 - f) * 0.0025000000000000001F; if (f2 < 1.0F) { d2 *= 0.80000000000000004F; MotionY *= 0.80000000000000004F; } MotionX = (float)Math.Cos(f3) * d2; MotionZ = (float)Math.Sin(f3) * d2; if (PosY < Field_40095_c) { MotionY = MotionY + (1 - MotionY) * 0.014999999664723873F; } else { MotionY = MotionY + (-1 - MotionY) * 0.014999999664723873F; } } float f1 = 0.25F; if (IsInWater()) { for (int i = 0; i < 4; i++) { WorldObj.SpawnParticle("bubble", PosX - MotionX * (double)f1, PosY - MotionY * (double)f1, PosZ - MotionZ * (double)f1, MotionX, MotionY, MotionZ); } } else { WorldObj.SpawnParticle("portal", ((PosX - MotionX * (double)f1) + Rand.NextDouble() * 0.59999999999999998D) - 0.29999999999999999D, PosY - MotionY * (double)f1 - 0.5D, ((PosZ - MotionZ * (double)f1) + Rand.NextDouble() * 0.59999999999999998D) - 0.29999999999999999D, MotionX, MotionY, MotionZ); } if (!WorldObj.IsRemote) { SetPosition(PosX, PosY, PosZ); DespawnTimer++; if (DespawnTimer > 80 && !WorldObj.IsRemote) { SetDead(); if (ShatterOrDrop) { WorldObj.SpawnEntityInWorld(new EntityItem(WorldObj, PosX, PosY, PosZ, new ItemStack(Item.EyeOfEnder))); } else { WorldObj.PlayAuxSFX(2003, (int)Math.Round(PosX), (int)Math.Round(PosY), (int)Math.Round(PosZ), 0); } } } }
/// <summary> /// Called to update the entity's position/logic. /// </summary> public override void OnUpdate() { base.OnUpdate(); if (PrevRotationPitch == 0.0F && PrevRotationYaw == 0.0F) { float f = MathHelper2.Sqrt_double(MotionX * MotionX + MotionZ * MotionZ); PrevRotationYaw = RotationYaw = (float)((Math.Atan2(MotionX, MotionZ) * 180D) / Math.PI); PrevRotationPitch = RotationPitch = (float)((Math.Atan2(MotionY, f) * 180D) / Math.PI); } int i = WorldObj.GetBlockId(XTile, YTile, ZTile); if (i > 0) { Block.BlocksList[i].SetBlockBoundsBasedOnState(WorldObj, XTile, YTile, ZTile); AxisAlignedBB axisalignedbb = Block.BlocksList[i].GetCollisionBoundingBoxFromPool(WorldObj, XTile, YTile, ZTile); if (axisalignedbb != null && axisalignedbb.IsVecInside(Vec3D.CreateVector(PosX, PosY, PosZ))) { InGround = true; } } if (ArrowShake > 0) { ArrowShake--; } if (InGround) { int j = WorldObj.GetBlockId(XTile, YTile, ZTile); int k = WorldObj.GetBlockMetadata(XTile, YTile, ZTile); if (j != InTile || k != InData) { InGround = false; MotionX *= Rand.NextFloat() * 0.2F; MotionY *= Rand.NextFloat() * 0.2F; MotionZ *= Rand.NextFloat() * 0.2F; TicksInGround = 0; TicksInAir = 0; return; } TicksInGround++; if (TicksInGround == 1200) { SetDead(); } return; } TicksInAir++; Vec3D vec3d = Vec3D.CreateVector(PosX, PosY, PosZ); Vec3D vec3d1 = Vec3D.CreateVector(PosX + MotionX, PosY + MotionY, PosZ + MotionZ); MovingObjectPosition movingobjectposition = WorldObj.RayTraceBlocks_do_do(vec3d, vec3d1, false, true); 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 l = 0; l < list.Count; l++) { Entity entity1 = list[l]; if (!entity1.CanBeCollidedWith() || entity1 == ShootingEntity && TicksInAir < 5) { continue; } float f5 = 0.3F; AxisAlignedBB axisalignedbb1 = entity1.BoundingBox.Expand(f5, f5, f5); MovingObjectPosition movingobjectposition1 = axisalignedbb1.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) { if (movingobjectposition.EntityHit != null) { float f1 = MathHelper2.Sqrt_double(MotionX * MotionX + MotionY * MotionY + MotionZ * MotionZ); int j1 = (int)Math.Ceiling((double)f1 * Damage); if (ArrowCritical) { j1 += Rand.Next(j1 / 2 + 2); } DamageSource damagesource = null; if (ShootingEntity == null) { damagesource = DamageSource.CauseArrowDamage(this, this); } else { damagesource = DamageSource.CauseArrowDamage(this, ShootingEntity); } if (IsBurning()) { movingobjectposition.EntityHit.SetFire(5); } if (movingobjectposition.EntityHit.AttackEntityFrom(damagesource, j1)) { if (movingobjectposition.EntityHit is EntityLiving) { ((EntityLiving)movingobjectposition.EntityHit).ArrowHitTempCounter++; if (Field_46027_au > 0) { float f7 = MathHelper2.Sqrt_double(MotionX * MotionX + MotionZ * MotionZ); if (f7 > 0.0F) { movingobjectposition.EntityHit.AddVelocity((MotionX * Field_46027_au * 0.60000002384185791F) / f7, 0.10000000000000001F, (MotionZ * Field_46027_au * 0.60000002384185791F) / f7); } } } WorldObj.PlaySoundAtEntity(this, "random.bowhit", 1.0F, 1.2F / (Rand.NextFloat() * 0.2F + 0.9F)); SetDead(); } else { MotionX *= -0.10000000149011612F; MotionY *= -0.10000000149011612F; MotionZ *= -0.10000000149011612F; RotationYaw += 180F; PrevRotationYaw += 180F; TicksInAir = 0; } } else { XTile = movingobjectposition.BlockX; YTile = movingobjectposition.BlockY; ZTile = movingobjectposition.BlockZ; InTile = WorldObj.GetBlockId(XTile, YTile, ZTile); InData = WorldObj.GetBlockMetadata(XTile, YTile, ZTile); MotionX = (float)(movingobjectposition.HitVec.XCoord - PosX); MotionY = (float)(movingobjectposition.HitVec.YCoord - PosY); MotionZ = (float)(movingobjectposition.HitVec.ZCoord - PosZ); float f2 = MathHelper2.Sqrt_double(MotionX * MotionX + MotionY * MotionY + MotionZ * MotionZ); PosX -= (MotionX / f2) * 0.05000000074505806F; PosY -= (MotionY / f2) * 0.05000000074505806F; PosZ -= (MotionZ / f2) * 0.05000000074505806F; WorldObj.PlaySoundAtEntity(this, "random.bowhit", 1.0F, 1.2F / (Rand.NextFloat() * 0.2F + 0.9F)); InGround = true; ArrowShake = 7; ArrowCritical = false; } } if (ArrowCritical) { for (int i1 = 0; i1 < 4; i1++) { WorldObj.SpawnParticle("crit", PosX + (MotionX * (double)i1) / 4D, PosY + (MotionY * (double)i1) / 4D, PosZ + (MotionZ * (double)i1) / 4D, -MotionX, -MotionY + 0.20000000000000001D, -MotionZ); } } PosX += MotionX; PosY += MotionY; PosZ += MotionZ; float f3 = MathHelper2.Sqrt_double(MotionX * MotionX + MotionZ * MotionZ); RotationYaw = (float)((Math.Atan2(MotionX, MotionZ) * 180D) / Math.PI); for (RotationPitch = (float)((Math.Atan2(MotionY, f3) * 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 f4 = 0.99F; float f6 = 0.05F; if (IsInWater()) { for (int k1 = 0; k1 < 4; k1++) { float f8 = 0.25F; WorldObj.SpawnParticle("bubble", PosX - MotionX * (double)f8, PosY - MotionY * (double)f8, PosZ - MotionZ * (double)f8, MotionX, MotionY, MotionZ); } f4 = 0.8F; } MotionX *= f4; MotionY *= f4; MotionZ *= f4; MotionY -= f6; SetPosition(PosX, PosY, PosZ); }
/// <summary> /// Does the second part of explosion (sound, particles, drop spawn) /// </summary> public virtual void DoExplosionB(bool par1) { WorldObj.PlaySoundEffect(ExplosionX, ExplosionY, ExplosionZ, "random.explode", 4F, (1.0F + (WorldObj.Rand.NextFloat() - WorldObj.Rand.NextFloat()) * 0.2F) * 0.7F); WorldObj.SpawnParticle("hugeexplosion", ExplosionX, ExplosionY, ExplosionZ, 0.0F, 0.0F, 0.0F); List <ChunkPosition> arraylist = new List <ChunkPosition>(); arraylist.AddRange(DestroyedBlockPositions); for (int i = arraylist.Count - 1; i >= 0; i--) { ChunkPosition chunkposition = arraylist[i]; int k = chunkposition.x; int i1 = chunkposition.y; int k1 = chunkposition.z; int i2 = WorldObj.GetBlockId(k, i1, k1); if (par1) { double d = (float)k + WorldObj.Rand.NextFloat(); double d1 = (float)i1 + WorldObj.Rand.NextFloat(); double d2 = (float)k1 + WorldObj.Rand.NextFloat(); double d3 = d - ExplosionX; double d4 = d1 - ExplosionY; double d5 = d2 - ExplosionZ; double d6 = MathHelper2.Sqrt_double(d3 * d3 + d4 * d4 + d5 * d5); d3 /= d6; d4 /= d6; d5 /= d6; double d7 = 0.5D / (d6 / (double)ExplosionSize + 0.10000000000000001D); d7 *= WorldObj.Rand.NextFloat() * WorldObj.Rand.NextFloat() + 0.3F; d3 *= d7; d4 *= d7; d5 *= d7; WorldObj.SpawnParticle("explode", (d + ExplosionX * 1.0D) / 2D, (d1 + ExplosionY * 1.0D) / 2D, (d2 + ExplosionZ * 1.0D) / 2D, d3, d4, d5); WorldObj.SpawnParticle("smoke", d, d1, d2, d3, d4, d5); } if (i2 > 0) { Block.BlocksList[i2].DropBlockAsItemWithChance(WorldObj, k, i1, k1, WorldObj.GetBlockMetadata(k, i1, k1), 0.3F, 0); WorldObj.SetBlockWithNotify(k, i1, k1, 0); Block.BlocksList[i2].OnBlockDestroyedByExplosion(WorldObj, k, i1, k1); } } if (IsFlaming) { for (int j = arraylist.Count - 1; j >= 0; j--) { ChunkPosition chunkposition1 = arraylist[j]; int l = chunkposition1.x; int j1 = chunkposition1.y; int l1 = chunkposition1.z; int j2 = WorldObj.GetBlockId(l, j1, l1); int k2 = WorldObj.GetBlockId(l, j1 - 1, l1); if (j2 == 0 && Block.OpaqueCubeLookup[k2] && ExplosionRNG.Next(3) == 0) { WorldObj.SetBlockWithNotify(l, j1, l1, Block.Fire.BlockID); } } } }
/// <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); }
/// <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> /// Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons /// use this to react to sunlight and start to burn. /// </summary> public override void OnLivingUpdate() { Field_40173_aw = Field_40172_ax; if (!WorldObj.IsRemote) { DataWatcher.UpdateObject(16, Convert.ToInt32(Health)); } if (Health <= 0) { float f = (Rand.NextFloat() - 0.5F) * 8F; float f2 = (Rand.NextFloat() - 0.5F) * 4F; float f4 = (Rand.NextFloat() - 0.5F) * 8F; WorldObj.SpawnParticle("largeexplode", PosX + (double)f, PosY + 2D + (double)f2, PosZ + (double)f4, 0.0F, 0.0F, 0.0F); return; } UpdateDragonEnderCrystal(); float f1 = 0.2F / (MathHelper2.Sqrt_double(MotionX * MotionX + MotionZ * MotionZ) * 10F + 1.0F); f1 *= (float)Math.Pow(2D, MotionY); if (Field_40161_az) { Field_40172_ax += f1 * 0.5F; } else { Field_40172_ax += f1; } for (; RotationYaw >= 180F; RotationYaw -= 360F) { } for (; RotationYaw < -180F; RotationYaw += 360F) { } if (Field_40164_e < 0) { for (int i = 0; i < Field_40162_d.Length; i++) { Field_40162_d[i][0] = RotationYaw; Field_40162_d[i][1] = PosY; } } if (++Field_40164_e == Field_40162_d.Length) { Field_40164_e = 0; } Field_40162_d[Field_40164_e][0] = RotationYaw; Field_40162_d[Field_40164_e][1] = PosY; if (WorldObj.IsRemote) { if (NewPosRotationIncrements > 0) { float d = PosX + (NewPosX - PosX) / NewPosRotationIncrements; float d2 = PosY + (NewPosY - PosY) / NewPosRotationIncrements; float d4 = PosZ + (NewPosZ - PosZ) / NewPosRotationIncrements; double d6; for (d6 = NewRotationYaw - (double)RotationYaw; d6 < -180D; d6 += 360D) { } for (; d6 >= 180D; d6 -= 360D) { } RotationYaw += (float)d6 / NewPosRotationIncrements; RotationPitch += (float)(NewRotationPitch - RotationPitch) / NewPosRotationIncrements; NewPosRotationIncrements--; SetPosition(d, d2, d4); SetRotation(RotationYaw, RotationPitch); } } else { double d1 = TargetX - PosX; float d3 = TargetY - PosY; double d5 = TargetZ - PosZ; double d7 = d1 * d1 + d3 * d3 + d5 * d5; if (Target != null) { TargetX = Target.PosX; TargetZ = Target.PosZ; float d8 = TargetX - PosX; float d10 = TargetZ - PosZ; float d12 = (float)Math.Sqrt(d8 * d8 + d10 * d10); float d13 = (0.40000000596046448F + d12 / 80F) - 1.0F; if (d13 > 10F) { d13 = 10F; } TargetY = Target.BoundingBox.MinY + d13; } else { TargetX += Rand.NextGaussian() * 2F; TargetZ += Rand.NextGaussian() * 2F; } if (Field_40163_ay || d7 < 100D || d7 > 22500D || IsCollidedHorizontally || IsCollidedVertically) { Func_41006_aA(); } d3 /= MathHelper2.Sqrt_double(d1 * d1 + d5 * d5); float f10 = 0.6F; if (d3 < (double)(-f10)) { d3 = -f10; } if (d3 > (double)f10) { d3 = f10; } MotionY += d3 * 0.10000000149011612F; for (; RotationYaw < -180F; RotationYaw += 360F) { } for (; RotationYaw >= 180F; RotationYaw -= 360F) { } double d9 = 180D - (Math.Atan2(d1, d5) * 180D) / Math.PI; double d11; for (d11 = d9 - (double)RotationYaw; d11 < -180D; d11 += 360D) { } for (; d11 >= 180D; d11 -= 360D) { } if (d11 > 50D) { d11 = 50D; } if (d11 < -50D) { d11 = -50D; } Vec3D vec3d = Vec3D.CreateVector(TargetX - PosX, TargetY - PosY, TargetZ - PosZ).Normalize(); Vec3D vec3d1 = Vec3D.CreateVector(MathHelper2.Sin((RotationYaw * (float)Math.PI) / 180F), MotionY, -MathHelper2.Cos((RotationYaw * (float)Math.PI) / 180F)).Normalize(); float f18 = (float)(vec3d1.DotProduct(vec3d) + 0.5D) / 1.5F; if (f18 < 0.0F) { f18 = 0.0F; } RandomYawVelocity *= 0.8F; float f19 = MathHelper2.Sqrt_double(MotionX * MotionX + MotionZ * MotionZ) * 1.0F + 1.0F; double d14 = Math.Sqrt(MotionX * MotionX + MotionZ * MotionZ) * 1.0D + 1.0D; if (d14 > 40D) { d14 = 40D; } RandomYawVelocity += (float)(d11 * (0.69999998807907104D / d14 / f19)); RotationYaw += RandomYawVelocity * 0.1F; float f20 = (float)(2D / (d14 + 1.0D)); float f21 = 0.06F; MoveFlying(0.0F, -1F, f21 * (f18 * f20 + (1.0F - f20))); if (Field_40161_az) { MoveEntity(MotionX * 0.80000001192092896F, MotionY * 0.80000001192092896F, MotionZ * 0.80000001192092896F); } else { MoveEntity(MotionX, MotionY, MotionZ); } Vec3D vec3d2 = Vec3D.CreateVector(MotionX, MotionY, MotionZ).Normalize(); float f22 = (float)(vec3d2.DotProduct(vec3d1) + 1.0D) / 2.0F; f22 = 0.8F + 0.15F * f22; MotionX *= f22; MotionZ *= f22; MotionY *= 0.9100000262260437F; } RenderYawOffset = RotationYaw; DragonPartHead.Width = DragonPartHead.Height = 3F; DragonPartTail1.Width = DragonPartTail1.Height = 2.0F; DragonPartTail2.Width = DragonPartTail2.Height = 2.0F; DragonPartTail3.Width = DragonPartTail3.Height = 2.0F; DragonPartBody.Height = 3F; DragonPartBody.Width = 5F; DragonPartWing1.Height = 2.0F; DragonPartWing1.Width = 4F; DragonPartWing2.Height = 3F; DragonPartWing2.Width = 4F; float f3 = (((float)(Func_40160_a(5, 1.0F)[1] - Func_40160_a(10, 1.0F)[1]) * 10F) / 180F) * (float)Math.PI; float f5 = MathHelper2.Cos(f3); float f6 = -MathHelper2.Sin(f3); float f7 = (RotationYaw * (float)Math.PI) / 180F; float f8 = MathHelper2.Sin(f7); float f9 = MathHelper2.Cos(f7); DragonPartBody.OnUpdate(); DragonPartBody.SetLocationAndAngles(PosX + (f8 * 0.5F), PosY, PosZ - (f9 * 0.5F), 0.0F, 0.0F); DragonPartWing1.OnUpdate(); DragonPartWing1.SetLocationAndAngles(PosX + (f9 * 4.5F), PosY + 2F, PosZ + (f8 * 4.5F), 0.0F, 0.0F); DragonPartWing2.OnUpdate(); DragonPartWing2.SetLocationAndAngles(PosX - (f9 * 4.5F), PosY + 2F, PosZ - (f8 * 4.5F), 0.0F, 0.0F); if (!WorldObj.IsRemote) { Func_41007_az(); } if (!WorldObj.IsRemote && MaxHurtTime == 0) { CollideWithEntities(WorldObj.GetEntitiesWithinAABBExcludingEntity(this, DragonPartWing1.BoundingBox.Expand(4, 2, 4).Offset(0.0F, -2F, 0.0F))); CollideWithEntities(WorldObj.GetEntitiesWithinAABBExcludingEntity(this, DragonPartWing2.BoundingBox.Expand(4, 2, 4).Offset(0.0F, -2F, 0.0F))); AttackEntitiesInList(WorldObj.GetEntitiesWithinAABBExcludingEntity(this, DragonPartHead.BoundingBox.Expand(1.0F, 1.0F, 1.0F))); } float[] ad = Func_40160_a(5, 1.0F); float[] ad1 = Func_40160_a(0, 1.0F); float f11 = MathHelper2.Sin((RotationYaw * (float)Math.PI) / 180F - RandomYawVelocity * 0.01F); float f12 = MathHelper2.Cos((RotationYaw * (float)Math.PI) / 180F - RandomYawVelocity * 0.01F); DragonPartHead.OnUpdate(); DragonPartHead.SetLocationAndAngles(PosX + (f11 * 5.5F * f5), PosY + (ad1[1] - ad[1]) * 1.0F + (f6 * 5.5F), PosZ - (f12 * 5.5F * f5), 0.0F, 0.0F); for (int j = 0; j < 3; j++) { EntityDragonPart entitydragonpart = null; if (j == 0) { entitydragonpart = DragonPartTail1; } if (j == 1) { entitydragonpart = DragonPartTail2; } if (j == 2) { entitydragonpart = DragonPartTail3; } float[] ad2 = Func_40160_a(12 + j * 2, 1.0F); float f13 = (RotationYaw * (float)Math.PI) / 180F + ((SimplifyAngle(ad2[0] - ad[0]) * (float)Math.PI) / 180F) * 1.0F; float f14 = MathHelper2.Sin(f13); float f15 = MathHelper2.Cos(f13); float f16 = 1.5F; float f17 = (float)(j + 1) * 2.0F; entitydragonpart.OnUpdate(); entitydragonpart.SetLocationAndAngles(PosX - ((f8 * f16 + f14 * f17) * f5), ((PosY + (ad2[1] - ad[1]) * 1.0F) - ((f17 + f16) * f6)) + 1.5F, PosZ + ((f9 * f16 + f15 * f17) * f5), 0.0F, 0.0F); } if (!WorldObj.IsRemote) { Field_40161_az = DestroyBlocksInAABB(DragonPartHead.BoundingBox) | DestroyBlocksInAABB(DragonPartBody.BoundingBox); } }
/// <summary> /// Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons /// use this to react to sunlight and start to burn. /// </summary> public override void OnLivingUpdate() { base.OnLivingUpdate(); Field_21088_b = Field_21089_a; Field_21086_f = Field_21087_c; Field_21084_h = Field_21085_g; LastTentacleAngle = TentacleAngle; Field_21085_g += Field_21080_l; if (Field_21085_g > ((float)Math.PI * 2F)) { Field_21085_g -= ((float)Math.PI * 2F); if (Rand.Next(10) == 0) { Field_21080_l = (1.0F / (Rand.NextFloat() + 1.0F)) * 0.2F; } } if (IsInWater()) { if (Field_21085_g < (float)Math.PI) { float f = Field_21085_g / (float)Math.PI; TentacleAngle = MathHelper2.Sin(f * f * (float)Math.PI) * (float)Math.PI * 0.25F; if ((double)f > 0.75D) { RandomMotionSpeed = 1.0F; Field_21079_m = 1.0F; } else { Field_21079_m = Field_21079_m * 0.8F; } } else { TentacleAngle = 0.0F; RandomMotionSpeed = RandomMotionSpeed * 0.9F; Field_21079_m = Field_21079_m * 0.99F; } if (!WorldObj.IsRemote) { MotionX = RandomMotionVecX * RandomMotionSpeed; MotionY = RandomMotionVecY * RandomMotionSpeed; MotionZ = RandomMotionVecZ * RandomMotionSpeed; } float f1 = MathHelper2.Sqrt_double(MotionX * MotionX + MotionZ * MotionZ); RenderYawOffset += ((-(float)Math.Atan2(MotionX, MotionZ) * 180F) / (float)Math.PI - RenderYawOffset) * 0.1F; RotationYaw = RenderYawOffset; Field_21087_c = Field_21087_c + (float)Math.PI * Field_21079_m * 1.5F; Field_21089_a += ((-(float)Math.Atan2(f1, MotionY) * 180F) / (float)Math.PI - Field_21089_a) * 0.1F; } else { TentacleAngle = MathHelper2.Abs(MathHelper2.Sin(Field_21085_g)) * (float)Math.PI * 0.25F; if (!WorldObj.IsRemote) { MotionX = 0.0F; MotionY -= 0.080000000000000002F; MotionY *= 0.98000001907348633F; MotionZ = 0.0F; } Field_21089_a += (-90F - Field_21089_a) * 0.02F; } }
public override void UpdateEntityActionState() { if (!WorldObj.IsRemote && WorldObj.DifficultySetting == 0) { SetDead(); } DespawnEntity(); PrevAttackCounter = AttackCounter; float d = WaypointX - PosX; float d1 = WaypointY - PosY; float d2 = WaypointZ - PosZ; float d3 = (float)MathHelper2.Sqrt_double(d * d + d1 * d1 + d2 * d2); if (d3 < 1.0D || d3 > 60D) { WaypointX = PosX + ((Rand.NextFloat() * 2.0F - 1.0F) * 16F); WaypointY = PosY + ((Rand.NextFloat() * 2.0F - 1.0F) * 16F); WaypointZ = PosZ + ((Rand.NextFloat() * 2.0F - 1.0F) * 16F); } if (CourseChangeCooldown-- <= 0) { CourseChangeCooldown += Rand.Next(5) + 2; if (IsCourseTraversable(WaypointX, WaypointY, WaypointZ, d3)) { MotionX += (d / d3) * 0.10000000000000001F; MotionY += (d1 / d3) * 0.10000000000000001F; MotionZ += (d2 / d3) * 0.10000000000000001F; } else { WaypointX = PosX; WaypointY = PosY; WaypointZ = PosZ; } } if (TargetedEntity != null && TargetedEntity.IsDead) { TargetedEntity = null; } if (TargetedEntity == null || AggroCooldown-- <= 0) { TargetedEntity = WorldObj.GetClosestVulnerablePlayerToEntity(this, 100); if (TargetedEntity != null) { AggroCooldown = 20; } } double d4 = 64D; if (TargetedEntity != null && TargetedEntity.GetDistanceSqToEntity(this) < d4 * d4) { float d5 = TargetedEntity.PosX - PosX; float d6 = (TargetedEntity.BoundingBox.MinY + TargetedEntity.Height / 2.0F) - PosY + (Height / 2.0F); float d7 = TargetedEntity.PosZ - PosZ; RenderYawOffset = RotationYaw = (-(float)Math.Atan2(d5, d7) * 180F) / (float)Math.PI; if (CanEntityBeSeen(TargetedEntity)) { if (AttackCounter == 10) { WorldObj.PlayAuxSFXAtEntity(null, 1007, (int)PosX, (int)PosY, (int)PosZ, 0); } AttackCounter++; if (AttackCounter == 20) { WorldObj.PlayAuxSFXAtEntity(null, 1008, (int)PosX, (int)PosY, (int)PosZ, 0); EntityFireball entityfireball = new EntityFireball(WorldObj, this, d5, d6, d7); float d8 = 4; Vec3D vec3d = GetLook(1.0F); entityfireball.PosX = PosX + (float)vec3d.XCoord * d8; entityfireball.PosY = PosY + (Height / 2.0F) + 0.5F; entityfireball.PosZ = PosZ + (float)vec3d.ZCoord * d8; WorldObj.SpawnEntityInWorld(entityfireball); AttackCounter = -40; } } else if (AttackCounter > 0) { AttackCounter--; } } else { RenderYawOffset = RotationYaw = (-(float)Math.Atan2(MotionX, MotionZ) * 180F) / (float)Math.PI; if (AttackCounter > 0) { AttackCounter--; } } if (!WorldObj.IsRemote) { byte byte0 = DataWatcher.GetWatchableObjectByte(16); byte byte1 = (byte)(AttackCounter <= 10 ? 0 : 1); if (byte0 != byte1) { DataWatcher.UpdateObject(16, byte1); } } }
/// <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); }