Exemple #1
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>
        /// Updates the task
        /// </summary>
        public override void UpdateTask()
        {
            TheVillager.GetLookHelper().SetLookPositionWithEntity(TheGolem, 30F, 30F);

            if (TheGolem.Func_48117_D_() == Field_48402_c)
            {
                TheVillager.GetNavigator().Func_48667_a(TheGolem, 0.15F);
                Field_48400_d = true;
            }

            if (Field_48400_d && TheVillager.GetDistanceSqToEntity(TheGolem) < 4D)
            {
                TheGolem.Func_48116_a(false);
                TheVillager.GetNavigator().ClearPathEntity();
            }
        }
        /// <summary>
        /// Updates the task
        /// </summary>
        public override void UpdateTask()
        {
            MatingTimeout--;
            VillagerObj.GetLookHelper().SetLookPositionWithEntity(Mate, 10F, 30F);

            if (VillagerObj.GetDistanceSqToEntity(Mate) > 2.25D)
            {
                VillagerObj.GetNavigator().Func_48667_a(Mate, 0.25F);
            }
            else if (MatingTimeout == 0 && Mate.GetIsMatingFlag())
            {
                GiveBirth();
            }

            if (VillagerObj.GetRNG().Next(35) == 0)
            {
                SpawnHeartParticles(VillagerObj);
            }
        }
Exemple #4
0
        /// <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);
            }
        }