/// <summary>
        /// Returns whether the EntityAIBase should begin execution.
        /// </summary>
        public override bool ShouldExecute()
        {
            if (VillagerObj.GetGrowingAge() != 0)
            {
                return(false);
            }

            if (VillagerObj.GetRNG().Next(500) != 0)
            {
                return(false);
            }

            VillageObj = WorldObj.VillageCollectionObj.FindNearestVillage(MathHelper2.Floor_double(VillagerObj.PosX), MathHelper2.Floor_double(VillagerObj.PosY), MathHelper2.Floor_double(VillagerObj.PosZ), 0);

            if (VillageObj == null)
            {
                return(false);
            }

            if (!CheckSufficientDoorsPresentForNewVillager())
            {
                return(false);
            }

            Entity entity = WorldObj.FindNearestEntityWithinAABB(typeof(net.minecraft.src.EntityVillager), VillagerObj.BoundingBox.Expand(8, 3, 8), VillagerObj);

            if (entity == null)
            {
                return(false);
            }

            Mate = (EntityVillager)entity;
            return(Mate.GetGrowingAge() == 0);
        }
Beispiel #2
0
        /// <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>
 /// Execute a one shot task or start executing a continuous task
 /// </summary>
 public override void StartExecuting()
 {
     Field_48402_c = TheVillager.GetRNG().Next(320);
     Field_48400_d = false;
     TheGolem.GetNavigator().ClearPathEntity();
 }