/// <summary> /// sets the active path data if path is 100% unique compared to old path, checks to adjust path for sun avoiding /// ents and stores end coords /// </summary> public virtual bool SetPath(PathEntity par1PathEntity, float par2) { if (par1PathEntity == null) { CurrentPath = null; return(false); } if (!par1PathEntity.Func_48647_a(CurrentPath)) { CurrentPath = par1PathEntity; } if (NoSunPathfind) { RemoveSunnyPath(); } if (CurrentPath.GetCurrentPathLength() == 0) { return(false); } else { Speed = par2; Vec3D vec3d = GetEntityPosition(); TicksAtLastPos = TotalTicks; LastPosCheck.XCoord = vec3d.XCoord; LastPosCheck.YCoord = vec3d.YCoord; LastPosCheck.ZCoord = vec3d.ZCoord; return(true); } }
/// <summary> /// Time remaining during which the Animal is sped up and flees. /// </summary> protected virtual void UpdateWanderPath() { Profiler.StartSection("stroll"); bool flag = false; int i = -1; int j = -1; int k = -1; float f = -99999F; for (int l = 0; l < 10; l++) { int i1 = MathHelper2.Floor_double((PosX + (double)Rand.Next(13)) - 6D); int j1 = MathHelper2.Floor_double((PosY + (double)Rand.Next(7)) - 3D); int k1 = MathHelper2.Floor_double((PosZ + (double)Rand.Next(13)) - 6D); float f1 = GetBlockPathWeight(i1, j1, k1); if (f1 > f) { f = f1; i = i1; j = j1; k = k1; flag = true; } } if (flag) { PathToEntity = WorldObj.GetEntityPathToXYZ(this, i, j, k, 10F, true, false, false, true); } Profiler.EndSection(); }
/// <summary> /// Returns whether the EntityAIBase should begin execution. /// </summary> public override bool ShouldExecute() { if (TargetEntityClass == (typeof(net.minecraft.src.EntityPlayer))) { if ((TheEntity is EntityTameable) && ((EntityTameable)TheEntity).IsTamed()) { return(false); } Field_48240_d = TheEntity.WorldObj.GetClosestPlayerToEntity(TheEntity, Field_48241_e); if (Field_48240_d == null) { return(false); } } else { List <Entity> list = TheEntity.WorldObj.GetEntitiesWithinAABB(TargetEntityClass, TheEntity.BoundingBox.Expand(Field_48241_e, 3, Field_48241_e)); if (list.Count == 0) { return(false); } Field_48240_d = list[0]; } if (!TheEntity.Func_48090_aM().CanSee(Field_48240_d)) { return(false); } Vec3D vec3d = RandomPositionGenerator.Func_48623_b(TheEntity, 16, 7, Vec3D.CreateVector(Field_48240_d.PosX, Field_48240_d.PosY, Field_48240_d.PosZ)); if (vec3d == null) { return(false); } if (Field_48240_d.GetDistanceSq((float)vec3d.XCoord, (float)vec3d.YCoord, (float)vec3d.ZCoord) < Field_48240_d.GetDistanceSqToEntity(TheEntity)) { return(false); } Field_48238_f = EntityPathNavigate.GetPathToXYZ(vec3d.XCoord, vec3d.YCoord, vec3d.ZCoord); if (Field_48238_f == null) { return(false); } return(Field_48238_f.Func_48639_a(vec3d)); }
public virtual bool Func_48667_a(EntityLiving par1EntityLiving, float par2) { PathEntity pathentity = Func_48679_a(par1EntityLiving); if (pathentity != null) { return(SetPath(pathentity, par2)); } else { return(false); } }
/// <summary> /// Returns whether the EntityAIBase should begin execution. /// </summary> public override bool ShouldExecute() { Func_48286_h(); if (Field_48289_e && TheEntity.WorldObj.IsDaytime()) { return(false); } Village village = TheEntity.WorldObj.VillageCollectionObj.FindNearestVillage(MathHelper2.Floor_double(TheEntity.PosX), MathHelper2.Floor_double(TheEntity.PosY), MathHelper2.Floor_double(TheEntity.PosZ), 0); if (village == null) { return(false); } DoorInfo = Func_48284_a(village); if (DoorInfo == null) { return(false); } bool flag = TheEntity.GetNavigator().Func_48665_b(); TheEntity.GetNavigator().SetBreakDoors(false); Field_48291_c = TheEntity.GetNavigator().GetPathToXYZ(DoorInfo.PosX, DoorInfo.PosY, DoorInfo.PosZ); TheEntity.GetNavigator().SetBreakDoors(flag); if (Field_48291_c != null) { return(true); } Vec3D vec3d = RandomPositionGenerator.Func_48620_a(TheEntity, 10, 7, Vec3D.CreateVector(DoorInfo.PosX, DoorInfo.PosY, DoorInfo.PosZ)); if (vec3d == null) { return(false); } else { TheEntity.GetNavigator().SetBreakDoors(false); Field_48291_c = TheEntity.GetNavigator().GetPathToXYZ(vec3d.XCoord, vec3d.YCoord, vec3d.ZCoord); TheEntity.GetNavigator().SetBreakDoors(flag); return(Field_48291_c != null); } }
/// <summary> /// Returns whether the EntityAIBase should begin execution. /// </summary> public override bool ShouldExecute() { EntityLiving entityliving = Attacker.GetAttackTarget(); if (entityliving == null) { return(false); } if (ClassTarget != null && !ClassTarget.IsAssignableFrom(entityliving.GetType())) { return(false); } else { EntityTarget = entityliving; Field_48265_g = Attacker.GetNavigator().Func_48679_a(EntityTarget); return(Field_48265_g != null); } }
/// <summary> /// Returns whether the EntityAIBase should begin execution. /// </summary> public override bool ShouldExecute() { if (!TheEntity.IsCollidedHorizontally) { return(false); } PathNavigate pathnavigate = TheEntity.GetNavigator(); PathEntity pathentity = pathnavigate.GetPath(); if (pathentity == null || pathentity.IsFinished() || !pathnavigate.Func_48665_b()) { return(false); } for (int i = 0; i < Math.Min(pathentity.GetCurrentPathIndex() + 2, pathentity.GetCurrentPathLength()); i++) { PathPoint pathpoint = pathentity.GetPathPointFromIndex(i); EntityPosX = pathpoint.XCoord; EntityPosY = pathpoint.YCoord + 1; EntityPosZ = pathpoint.ZCoord; if (TheEntity.GetDistanceSq(EntityPosX, TheEntity.PosY, EntityPosZ) > 2.25D) { continue; } TargetDoor = Func_48318_a(EntityPosX, EntityPosY, EntityPosZ); if (TargetDoor != null) { return(true); } } EntityPosX = MathHelper2.Floor_double(TheEntity.PosX); EntityPosY = MathHelper2.Floor_double(TheEntity.PosY + 1.0D); EntityPosZ = MathHelper2.Floor_double(TheEntity.PosZ); TargetDoor = Func_48318_a(EntityPosX, EntityPosY, EntityPosZ); return(TargetDoor != null); }
/// <summary> /// sets active PathEntity to null /// </summary> public virtual void ClearPathEntity() { CurrentPath = null; }
public virtual bool Func_48666_a(double par1, double par3, double par5, float par7) { PathEntity pathentity = GetPathToXYZ(MathHelper2.Floor_double(par1), (int)par3, MathHelper2.Floor_double(par5)); return(SetPath(pathentity, par7)); }
public override void UpdateEntityActionState() { Profiler.StartSection("ai"); if (FleeingTick > 0) { FleeingTick--; } HasAttacked = IsMovementCeased(); float f = 16F; if (EntityToAttack == null) { EntityToAttack = FindPlayerToAttack(); if (EntityToAttack != null) { PathToEntity = WorldObj.GetPathEntityToEntity(this, EntityToAttack, f, true, false, false, true); } } else if (!EntityToAttack.IsEntityAlive()) { EntityToAttack = null; } else { float f1 = EntityToAttack.GetDistanceToEntity(this); if (CanEntityBeSeen(EntityToAttack)) { AttackEntity(EntityToAttack, f1); } else { AttackBlockedEntity(EntityToAttack, f1); } } Profiler.EndSection(); if (!HasAttacked && EntityToAttack != null && (PathToEntity == null || Rand.Next(20) == 0)) { PathToEntity = WorldObj.GetPathEntityToEntity(this, EntityToAttack, f, true, false, false, true); } else if (!HasAttacked && (PathToEntity == null && Rand.Next(180) == 0 || Rand.Next(120) == 0 || FleeingTick > 0) && EntityAge < 100) { UpdateWanderPath(); } int i = MathHelper2.Floor_double(BoundingBox.MinY + 0.5D); bool flag = IsInWater(); bool flag1 = HandleLavaMovement(); RotationPitch = 0.0F; if (PathToEntity == null || Rand.Next(100) == 0) { base.UpdateEntityActionState(); PathToEntity = null; return; } Profiler.StartSection("followpath"); Vec3D vec3d = PathToEntity.GetCurrentNodeVec3d(this); for (double d = Width * 2.0F; vec3d != null && vec3d.SquareDistanceTo(PosX, vec3d.YCoord, PosZ) < d * d;) { PathToEntity.IncrementPathIndex(); if (PathToEntity.IsFinished()) { vec3d = null; PathToEntity = null; } else { vec3d = PathToEntity.GetCurrentNodeVec3d(this); } } IsJumping = false; if (vec3d != null) { double d1 = vec3d.XCoord - PosX; double d2 = vec3d.ZCoord - PosZ; double d3 = vec3d.YCoord - (double)i; float f2 = (float)((Math.Atan2(d2, d1) * 180D) / Math.PI) - 90F; float f3 = f2 - RotationYaw; MoveForward = MoveSpeed; for (; f3 < -180F; f3 += 360F) { } for (; f3 >= 180F; f3 -= 360F) { } if (f3 > 30F) { f3 = 30F; } if (f3 < -30F) { f3 = -30F; } RotationYaw += f3; if (HasAttacked && EntityToAttack != null) { double d4 = EntityToAttack.PosX - PosX; double d5 = EntityToAttack.PosZ - PosZ; float f5 = RotationYaw; RotationYaw = (float)((Math.Atan2(d5, d4) * 180D) / Math.PI) - 90F; float f4 = (((f5 - RotationYaw) + 90F) * (float)Math.PI) / 180F; MoveStrafing = -MathHelper2.Sin(f4) * MoveForward * 1.0F; MoveForward = MathHelper2.Cos(f4) * MoveForward * 1.0F; } if (d3 > 0.0F) { IsJumping = true; } } if (EntityToAttack != null) { FaceEntity(EntityToAttack, 30F, 30F); } if (IsCollidedHorizontally && !HasPath()) { IsJumping = true; } if (Rand.NextFloat() < 0.8F && (flag || flag1)) { IsJumping = true; } Profiler.EndSection(); }
/// <summary> /// sets the Entities walk path in EntityCreature /// </summary> public virtual void SetPathToEntity(PathEntity par1PathEntity) { PathToEntity = par1PathEntity; }