/** Returns whether the EntityAIBase should begin execution. */ public boolean shouldExecute() { if (villagerObj.getGrowingAge() >= 0) { return false; } if (villagerObj.getRNG().nextInt(400) != 0) { return false; } List list = villagerObj.worldObj.getEntitiesWithinAABB( net.minecraft.src.EntityVillager.class, villagerObj.boundingBox.expand(6D, 3D, 6D)); double d = Double.MAX_VALUE; Iterator iterator = list.iterator(); do { if (!iterator.hasNext()) { break; } EntityVillager entityvillager = (EntityVillager) iterator.next(); if (entityvillager != villagerObj && !entityvillager.isPlaying() && entityvillager.getGrowingAge() < 0) { double d1 = entityvillager.getDistanceSqToEntity(villagerObj); if (d1 <= d) { d = d1; targetVillager = entityvillager; } } } while (true); if (targetVillager == null) { Vec3 vec3 = RandomPositionGenerator.func_75463_a(villagerObj, 16, 3); if (vec3 == null) { return false; } } return true; }
/** Execute a one shot task or start executing a continuous task */ public void startExecuting() { field_48215_c = theVillager.getRNG().nextInt(320); field_48213_d = false; theGolem.getNavigator().clearPathEntity(); }