/** Execute a one shot task or start executing a continuous task */
  public void updateTask() {
    this.insidePosX = -1;
    if (this.isRestTime() && this.isPrevTerepo()) {
      this.theFarmers.setDEHomePos(
          this.theFarmers.posX, this.theFarmers.posY, this.theFarmers.posZ);

      if (this.theFarmers.getDistanceSq(
              this.gateInfo.getInsidePosX(), this.gateInfo.posY, this.gateInfo.getInsidePosZ())
          > 256.0D) {
        Vec3 var1 =
            RandomPositionGenerator.findRandomTargetBlockTowards(
                this.theFarmers,
                14,
                3,
                this.theFarmers
                    .worldObj
                    .getWorldVec3Pool()
                    .getVecFromPool(
                        this.gateInfo.getInsidePosX() + 0.5D,
                        this.gateInfo.getInsidePosY(),
                        this.gateInfo.getInsidePosZ() + 0.5D));

        if (var1 != null) {
          // this.entityObj.getNavigator().tryMoveToXYZ(var1.xCoord, var1.yCoord, var1.zCoord,
          // 0.3F);
          if (this.teleportTo(var1.xCoord, var1.yCoord, var1.zCoord)) {
            this.theFarmers.homePos.isinHome = true;
          }
        }
      } else {
        // this.entityObj.getNavigator().tryMoveToXYZ((double)this.gateInfo.getInsidePosX() + 0.5D,
        // (double)this.gateInfo.getInsidePosY(), (double)this.gateInfo.getInsidePosZ() + 0.5D,
        // 0.3F);
        if (this.teleportTo(
            this.gateInfo.getInsidePosX() + 0.5D,
            this.gateInfo.getInsidePosY(),
            this.gateInfo.getInsidePosZ() + 0.5D)) {
          this.theFarmers.homePos.isinHome = true;
        }
      }
    } else if (this.hasHomesInfo() && !this.isRestTime()) {
      DEHomePosition homepos = this.theFarmers.homePos;

      if (this.teleportTo(homepos.posX, homepos.posY, homepos.posZ)) {
        this.theFarmers.homePos = null;
      }
    }
  }
  /** Returns whether the EntityAIBase should begin execution. */
  public boolean shouldExecute() {
    if (this.swimmingEntity.getRNG().nextFloat() < 0.50) {
      return false;
    }

    Vec3 vec3 = RandomPositionGenerator.findRandomTarget(this.swimmingEntity, 6, 2);

    if (vec3 == null) {
      return false;
    } else {
      this.xPosition = vec3.xCoord;
      this.yPosition = vec3.yCoord;
      this.zPosition = vec3.zCoord;
      return true;
    }
  }
  @Override
  public boolean shouldExecute() {
    if (!this.dragon.isStartled() || this.dragon.isTamed()) return false;

    if (this.avoidClass == EntityPlayer.class
        && (this.closestLiving =
                this.dragon.worldObj.getClosestPlayerToEntity(this.dragon, this.reactDist))
            == null) return false;
    else {
      List<?> list =
          this.dragon.worldObj.selectEntitiesWithinAABB(
              this.avoidClass,
              this.dragon.boundingBox.expand(this.reactDist, this.reactDist * 0.4, this.reactDist),
              new IEntitySelector() {
                @Override
                public boolean isEntityApplicable(Entity e) {
                  return e.isEntityAlive()
                      && EntityAIStartled.this.dragon.getEntitySenses().canSee(e);
                }
              });

      if (list.isEmpty()) return false;

      this.closestLiving = (EntityLivingBase) list.get(0);
    }

    if (!(this.willRun = this.dragon.getRNG().nextFloat() <= this.attackChance)) return true;

    Vec3 vec3 =
        RandomPositionGenerator.findRandomTargetBlockAwayFrom(
            this.dragon, 16, 7, this.closestLiving.getPosition(1));

    if (vec3 == null
        || this.closestLiving.getDistanceSq(vec3.xCoord, vec3.yCoord, vec3.zCoord)
            < this.closestLiving.getDistanceSqToEntity(this.dragon)) return false;
    else {
      this.entityPathEntity =
          this.dragon.getNavigator().getPathToXYZ(vec3.xCoord, vec3.yCoord, vec3.zCoord);
      return this.entityPathEntity == null ? false : this.entityPathEntity.isDestinationSame(vec3);
    }
  }
  /** Returns whether the EntityAIBase should begin execution. */
  public boolean shouldExecute() {
    if (this.entity.OrderStatus == null) {
      this.entity.OrderStatus = EnumOrderType.FreeMove;
    }

    if (this.entity.getRNG().nextInt(120) != 0) {
      return false;
    } else if (this.entity.isTamed() && this.entity.OrderStatus != EnumOrderType.FreeMove) {
      return false;
    } else {
      Vec3 vec3 = RandomPositionGenerator.findRandomTarget(this.entity, 10, 7);

      if (vec3 == null) {
        return false;
      } else {
        this.xPosition = vec3.xCoord;
        this.yPosition = vec3.yCoord;
        this.zPosition = vec3.zCoord;
        return true;
      }
    }
  }