/// <summary> /// Updates the task /// </summary> public override void UpdateTask() { Attacker.GetLookHelper().SetLookPositionWithEntity(EntityTarget, 30F, 30F); if ((Field_48264_f || Attacker.Func_48090_aM().CanSee(EntityTarget)) && --Field_48269_i <= 0) { Field_48269_i = 4 + Attacker.GetRNG().Next(7); Attacker.GetNavigator().Func_48667_a(EntityTarget, Field_48266_e); } Field_46091_d = Math.Max(Field_46091_d - 1, 0); double d = Attacker.Width * 2.0F * (Attacker.Width * 2.0F); if (Attacker.GetDistanceSq(EntityTarget.PosX, EntityTarget.BoundingBox.MinY, EntityTarget.PosZ) > d) { return; } if (Field_46091_d > 0) { return; } else { Field_46091_d = 20; Attacker.AttackEntityAsMob(EntityTarget); return; } }
/// <summary> /// Returns whether the EntityAIBase should begin execution. /// </summary> public override bool ShouldExecute() { if (Field_46105_a.GetRNG().NextFloat() >= Field_48294_e) { return(false); } if (Field_48293_f == (typeof(net.minecraft.src.EntityPlayer))) { ClosestEntity = Field_46105_a.WorldObj.GetClosestPlayerToEntity(Field_46105_a, Field_46101_d); } else { ClosestEntity = Field_46105_a.WorldObj.FindNearestEntityWithinAABB(Field_48293_f, Field_46105_a.BoundingBox.Expand(Field_46101_d, 3, Field_46101_d), Field_46105_a); } return(ClosestEntity != null); }
/// <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); } }
private void SpawnHeartParticles(EntityLiving par1EntityLiving) { Random random = par1EntityLiving.GetRNG(); for (int i = 0; i < 5; i++) { double d = random.NextGaussian() * 0.02D; double d1 = random.NextGaussian() * 0.02D; double d2 = random.NextGaussian() * 0.02D; WorldObj.SpawnParticle("heart", (par1EntityLiving.PosX + (double)(random.NextFloat() * par1EntityLiving.Width * 2.0F)) - (double)par1EntityLiving.Width, par1EntityLiving.PosY + 1.0D + (double)(random.NextFloat() * par1EntityLiving.Height), (par1EntityLiving.PosZ + (double)(random.NextFloat() * par1EntityLiving.Width * 2.0F)) - (double)par1EntityLiving.Width, d, d1, d2); } }
/// <summary> /// Returns whether the EntityAIBase should begin execution. /// </summary> public override bool ShouldExecute() { if (TheEntity.GetRNG().Next(TheEntity.IsChild() ? 50 : 1000) != 0) { return(false); } int i = MathHelper2.Floor_double(TheEntity.PosX); int j = MathHelper2.Floor_double(TheEntity.PosY); int k = MathHelper2.Floor_double(TheEntity.PosZ); if (TheWorld.GetBlockId(i, j, k) == Block.TallGrass.BlockID && TheWorld.GetBlockMetadata(i, j, k) == 1) { return(true); } return(TheWorld.GetBlockId(i, j - 1, k) == Block.Grass.BlockID); }
/// <summary> /// Returns whether the EntityAIBase should begin execution. /// </summary> public override bool ShouldExecute() { return(IdleEntity.GetRNG().NextFloat() < 0.02F); }