protected PathNavigate getNavigator() {
   if (entityHost.isRiding()) {
     Entity ent = entityHost.ridingEntity;
     if (ent instanceof EntityLiving) {
       return ((EntityLiving) ent).getNavigator();
     }
   }
   return entityHost.getNavigator();
 }
  /** Updates the task */
  @Override
  public void updateTask() {
    double distToTargetSq =
        entityHost.getDistanceSq(
            attackTarget.posX, attackTarget.boundingBox.minY, attackTarget.posZ);
    boolean canSeeTarget = entityHost.getEntitySenses().canSee(attackTarget);

    if (canSeeTarget) {
      ++timeTargetVisible;
    } else {
      timeTargetVisible = 0;
    }

    boolean runningAway = isRunningAway();
    if (!runningAway) {
      runAwayTimer--;
    }

    if (!runningAway && distToTargetSq <= attackRangeSq && timeTargetVisible >= 20) {
      getNavigator().clearPathEntity();
    } else if (distToTargetSq > (attackRangeSq * 0.9)) {
      getNavigator().tryMoveToEntityLiving(attackTarget, getMoveSpeed());
    }

    if (canSeeTarget
        && entityHost.isRiding()
        && distToTargetSq < 36
        && runAwayTimer <= 0
        && runAway()) {
      --timeUntilNextAttack;
      return;
    }

    if (runningAway) {
      --timeUntilNextAttack;
      return;
    }

    entityHost.getLookHelper().setLookPositionWithEntity(attackTarget, 30.0F, 30.0F);

    if (--timeUntilNextAttack == 0) {
      if (distToTargetSq > attackRangeSq || !canSeeTarget) {
        return;
      }
      float rangeRatio = MathHelper.sqrt_double(distToTargetSq) / attackRange;
      rangeRatio = MathHelper.clamp_float(rangeRatio, 0.1f, 1);
      rangedAttackEntityHost.attackEntityWithRangedAttack(attackTarget, rangeRatio);
      timeUntilNextAttack =
          MathHelper.floor_float(
              rangeRatio * (maxRangedAttackTime - minRangedAttackTime) + minRangedAttackTime);
    } else if (timeUntilNextAttack < 0) {
      float rangeRatio = MathHelper.sqrt_double(distToTargetSq) / attackRange;
      timeUntilNextAttack =
          MathHelper.floor_float(
              rangeRatio * (maxRangedAttackTime - minRangedAttackTime) + minRangedAttackTime);
    }
  }
 private double getMoveSpeed() {
   if (entityHost.isRiding()) {
     return mountedEntityMoveSpeed;
   }
   return entityMoveSpeed;
 }