Example #1
0
  public boolean func_75250_a() {
    if (this.field_75381_h == EntityPlayer.class) {
      if (this.field_75380_a instanceof EntityTameable
          && ((EntityTameable) this.field_75380_a).func_70909_n()) {
        return false;
      }

      this.field_75376_d =
          this.field_75380_a.field_70170_p.func_72890_a(
              this.field_75380_a, (double) this.field_75377_e);
      if (this.field_75376_d == null) {
        return false;
      }
    } else {
      List var1 =
          this.field_75380_a.field_70170_p.func_72872_a(
              this.field_75381_h,
              this.field_75380_a.field_70121_D.func_72314_b(
                  (double) this.field_75377_e, 3.0D, (double) this.field_75377_e));
      if (var1.isEmpty()) {
        return false;
      }

      this.field_75376_d = (Entity) var1.get(0);
    }

    if (!this.field_75380_a.func_70635_at().func_75522_a(this.field_75376_d)) {
      return false;
    } else {
      Vec3 var2 =
          RandomPositionGenerator.func_75461_b(
              this.field_75380_a,
              16,
              7,
              this.field_75380_a
                  .field_70170_p
                  .func_82732_R()
                  .func_72345_a(
                      this.field_75376_d.field_70165_t,
                      this.field_75376_d.field_70163_u,
                      this.field_75376_d.field_70161_v));
      if (var2 == null) {
        return false;
      } else if (this.field_75376_d.func_70092_e(
              var2.field_72450_a, var2.field_72448_b, var2.field_72449_c)
          < this.field_75376_d.func_70068_e(this.field_75380_a)) {
        return false;
      } else {
        this.field_75374_f =
            this.field_75375_g.func_75488_a(
                var2.field_72450_a, var2.field_72448_b, var2.field_72449_c);
        return this.field_75374_f == null ? false : this.field_75374_f.func_75880_b(var2);
      }
    }
  }
  /** Returns whether the EntityAIBase should begin execution. */
  public boolean shouldExecute() {
    if (this.targetEntityClass == EntityPlayer.class) {
      if (this.theEntity instanceof EntityTameable && ((EntityTameable) this.theEntity).isTamed()) {
        return false;
      }

      this.field_48233_d =
          this.theEntity.worldObj.getClosestPlayerToEntity(
              this.theEntity, (double) this.field_48234_e);

      if (this.field_48233_d == null) {
        return false;
      }
    } else {
      List var1 =
          this.theEntity.worldObj.getEntitiesWithinAABB(
              this.targetEntityClass,
              this.theEntity.boundingBox.expand(
                  (double) this.field_48234_e, 3.0D, (double) this.field_48234_e));

      if (var1.size() == 0) {
        return false;
      }

      this.field_48233_d = (Entity) var1.get(0);
    }

    if (!this.theEntity.getEntitySenses().canSee(this.field_48233_d)) {
      return false;
    } else {
      Vec3D var2 =
          RandomPositionGenerator.func_48394_b(
              this.theEntity,
              16,
              7,
              Vec3D.createVector(
                  this.field_48233_d.posX, this.field_48233_d.posY, this.field_48233_d.posZ));

      if (var2 == null) {
        return false;
      } else if (this.field_48233_d.getDistanceSq(var2.xCoord, var2.yCoord, var2.zCoord)
          < this.field_48233_d.getDistanceSqToEntity(this.theEntity)) {
        return false;
      } else {
        this.field_48231_f =
            this.entityPathNavigate.getPathToXYZ(var2.xCoord, var2.yCoord, var2.zCoord);
        return this.field_48231_f == null ? false : this.field_48231_f.isDestinationSame(var2);
      }
    }
  }
Example #3
0
 public boolean func_75250_a() {
   if (this.field_75267_a.func_70643_av() == null && !this.field_75267_a.func_70027_ad()) {
     return false;
   } else {
     Vec3 var1 = RandomPositionGenerator.func_75463_a(this.field_75267_a, 5, 4);
     if (var1 == null) {
       return false;
     } else {
       this.field_75266_c = var1.field_72450_a;
       this.field_75263_d = var1.field_72448_b;
       this.field_75264_e = var1.field_72449_c;
       return true;
     }
   }
 }
  /** Updates the task */
  public void updateTask() {
    playTime--;

    if (targetVillager != null) {
      if (villagerObj.getDistanceSqToEntity(targetVillager) > 4D) {
        villagerObj.getNavigator().tryMoveToEntityLiving(targetVillager, field_75261_c);
      }
    } else if (villagerObj.getNavigator().noPath()) {
      Vec3 vec3 = RandomPositionGenerator.func_75463_a(villagerObj, 16, 3);

      if (vec3 == null) {
        return;
      }

      villagerObj.getNavigator().tryMoveToXYZ(vec3.xCoord, vec3.yCoord, vec3.zCoord, field_75261_c);
    }
  }
  /** 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;
  }
  /** Returns whether the EntityAIBase should begin execution. */
  public boolean shouldExecute() {
    if (this.targetEntityClass == EntityPlayer.class) {
      if (this.theEntity instanceof EntityTameable && ((EntityTameable) this.theEntity).isTamed()) {
        return false;
      }

      this.closestLivingEntity =
          this.theEntity.worldObj.getClosestPlayerToEntity(
              this.theEntity, (double) this.distanceFromEntity);

      if (this.closestLivingEntity == null) {
        return false;
      }
    } else {
      List var1 =
          this.theEntity.worldObj.getEntitiesWithinAABB(
              this.targetEntityClass,
              this.theEntity.boundingBox.expand(
                  (double) this.distanceFromEntity, 3.0D, (double) this.distanceFromEntity));

      if (var1.isEmpty()) {
        return false;
      }

      this.closestLivingEntity = (Entity) var1.get(0);
    }

    if (!this.theEntity.getEntitySenses().canSee(this.closestLivingEntity)) {
      return false;
    } else {
      Vec3 var2 =
          RandomPositionGenerator.findRandomTargetBlockAwayFrom(
              this.theEntity,
              16,
              7,
              Vec3.getVec3Pool()
                  .getVecFromPool(
                      this.closestLivingEntity.posX,
                      this.closestLivingEntity.posY,
                      this.closestLivingEntity.posZ));

      if (var2 == null) {
        return false;
      } else if (this.closestLivingEntity.getDistanceSq(var2.xCoord, var2.yCoord, var2.zCoord)
          < this.closestLivingEntity.getDistanceSqToEntity(this.theEntity)) {
        return false;
      } else {
        if (!this.isMagicEffect) {
          this.entityPathEntity =
              this.entityPathNavigate.getPathToXYZ(var2.xCoord, var2.yCoord, var2.zCoord);
          return this.entityPathEntity == null
              ? false
              : this.entityPathEntity.isDestinationSame(var2);
        } else {
          if (this.theEntity.isPotionActive(Potion.flee)) {
            this.entityPathEntity =
                this.entityPathNavigate.getPathToXYZ(var2.xCoord, var2.yCoord, var2.zCoord);
            return this.entityPathEntity == null
                ? false
                : this.entityPathEntity.isDestinationSame(var2);
          } else {
            return false;
          }
        }
      }
    }
  }