protected void updateEntityActionState() {
    if (riddenByEntity != null) return;
    if (doesLand) {
      if (onGround
          && rand.nextInt(10) == 0
          && (motionX > 0.050000000000000003D
              || motionZ > 0.050000000000000003D
              || motionX < -0.050000000000000003D
              || motionZ < -0.050000000000000003D)) {
        motionY = 0.25D;
      }
      if (!fleeing) {
        super.updateEntityActionState();
      }
    } else {
      if (!this.worldObj.isRemote && this.worldObj.difficultySetting == 0) {
        this.setDead();
      }

      this.despawnEntity();
      double var1 = this.waypointX - this.posX;
      double var3 = this.waypointY - this.posY;
      double var5 = this.waypointZ - this.posZ;
      double var7 = (double) MathHelper.sqrt_double(var1 * var1 + var3 * var3 + var5 * var5);

      if (var7 < 1.0D || var7 > 60.0D) {
        this.waypointX = this.posX + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
        this.waypointY = this.posY + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
        this.waypointZ = this.posZ + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F);
      }

      if (this.courseChangeCooldown-- <= 0) {
        this.courseChangeCooldown += this.rand.nextInt(5) + 2;

        if (this.isCourseTraversable(this.waypointX, this.waypointY, this.waypointZ, var7)) {
          this.motionX += var1 / var7 * 0.1D;
          this.motionY += var3 / var7 * 0.1D;
          this.motionZ += var5 / var7 * 0.1D;
        } else {
          this.waypointX = this.posX;
          this.waypointY = this.posY;
          this.waypointZ = this.posZ;
        }
      }
      if (this.isAggressive) {
        if (this.targetedEntity != null && this.targetedEntity.isDead) {
          this.targetedEntity = null;
        }

        if (this.targetedEntity == null || this.aggroCooldown-- <= 0) {
          this.targetedEntity = this.worldObj.getClosestVulnerablePlayerToEntity(this, 100.0D);

          if (this.targetedEntity != null) {
            this.aggroCooldown = 20;
          }
        }

        double var9 = 64.0D;

        if (this.targetedEntity != null
            && ((Entity) this.targetedEntity).getDistanceSqToEntity(this) < var9 * var9) {
          double var11 = this.targetedEntity.posX - this.posX;
          double var13 =
              this.targetedEntity.boundingBox.minY
                  + (double) (this.targetedEntity.height / 2.0F)
                  - (this.posY + (double) (this.height / 2.0F));
          double var15 = this.targetedEntity.posZ - this.posZ;
          this.renderYawOffset =
              this.rotationYaw = -((float) Math.atan2(var11, var15)) * 180.0F / (float) Math.PI;

        } else {
          this.renderYawOffset =
              this.rotationYaw =
                  -((float) Math.atan2(this.motionX, this.motionZ)) * 180.0F / (float) Math.PI;

          if (this.attackCounter > 0) {
            --this.attackCounter;
          }
        }

        if (!this.worldObj.isRemote) {
          byte var21 = this.dataWatcher.getWatchableObjectByte(16);
          byte var12 = (byte) (this.attackCounter > 10 ? 1 : 0);

          if (var21 != var12) {
            this.dataWatcher.updateObject(16, Byte.valueOf(var12));
          }
        }
      }
    }
  }