/// <summary> /// Returns whether the EntityAIBase should begin execution. /// </summary> public override bool ShouldExecute() { if (VillagerObj.GetGrowingAge() >= 0) { return(false); } if (VillagerObj.GetRNG().Next(400) != 0) { return(false); } List <Entity> list = VillagerObj.WorldObj.GetEntitiesWithinAABB(typeof(net.minecraft.src.EntityVillager), VillagerObj.BoundingBox.Expand(6, 3, 6)); double d = double.MaxValue; IEnumerator <Entity> iterator = list.GetEnumerator(); do { if (!iterator.MoveNext()) { break; } Entity entity = iterator.Current; if (entity != VillagerObj) { EntityVillager entityvillager = (EntityVillager)entity; if (!entityvillager.GetIsPlayingFlag() && entityvillager.GetGrowingAge() < 0) { double d1 = entityvillager.GetDistanceSqToEntity(VillagerObj); if (d1 <= d) { d = d1; TargetVillager = entityvillager; } } } }while (true); if (TargetVillager == null) { Vec3D vec3d = RandomPositionGenerator.Func_48622_a(VillagerObj, 16, 3); if (vec3d == null) { return(false); } } return(true); }
/// <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)); }
/// <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> /// Updates the task /// </summary> public override void UpdateTask() { Field_48356_d--; if (TargetVillager != null) { if (VillagerObj.GetDistanceSqToEntity(TargetVillager) > 4D) { VillagerObj.GetNavigator().Func_48667_a(TargetVillager, Field_48358_c); } } else if (VillagerObj.GetNavigator().NoPath()) { Vec3D vec3d = RandomPositionGenerator.Func_48622_a(VillagerObj, 16, 3); if (vec3d == null) { return; } VillagerObj.GetNavigator().Func_48666_a(vec3d.XCoord, vec3d.YCoord, vec3d.ZCoord, Field_48358_c); } }