Exemplo n.º 1
0
  public void onLivingUpdate() {
    super.onLivingUpdate();
    // if (ridingHelper != null)
    // ridingHelper.onLivingUpdate();
    if (worldObj.isRemote) {
      motionX = motionY = motionZ = 0;
      return;
    }
    this.field_21085_g += this.field_21080_l;
    if (this.field_21085_g > ((float) Math.PI * 2F)) {
      this.field_21085_g -= ((float) Math.PI * 2F);
    }
    if (this.isInWater() && !isSwimming) {
      if (randomMotionSpeed <= swimSpeed / 2) randomMotionSpeed = swimSpeed;
      randomMotionSpeed *= decayRate;

      if (!worldObj.isRemote) {
        motionX = randomMotionVecX * randomMotionSpeed;
        motionY = randomMotionVecY * randomMotionSpeed * 0.05;
        motionZ = randomMotionVecZ * randomMotionSpeed;
      }

      renderYawOffset +=
          ((-(float) Math.atan2(motionX, motionZ) * 180F) / (float) Math.PI - renderYawOffset)
              * 0.1F;
      rotationYaw = renderYawOffset;
    } else {
      surfaceHeight = this.posY;
      this.motionX = 0.0D;
      this.motionY -= 0.08D;
      this.motionY *= 0.9800000190734863D;
      this.motionZ = 0.0D;
    }
  }
Exemplo n.º 2
0
  public void onLivingUpdate() {
    super.onLivingUpdate();
    if (riddenByEntity != null) return;
    winge = wingb;
    wingd = wingc;
    wingc = (float) ((double) wingc + (double) (onGround ? -1 : 4) * 0.29999999999999999D);
    if (wingc < 0.0F) {
      wingc = 0.0F;
    }
    if (wingc > 1.0F) {
      wingc = 1.0F;
    }
    if (onGround && !doesLand) motionY = 1F;
    if (!onGround && wingh < 1.0F) {
      wingh = 1.0F;
    }
    wingh = (float) ((double) wingh * 0.90000000000000002D);
    if (!onGround && motionY < 0.0D) {
      motionY *= 0.80000000000000004D;
    }
    wingb += wingh * 2.0F;
    EntityLiving entityliving = getClosestEntityLiving(this, 4D);
    if (entityliving != null && canEntityBeSeen(entityliving)) {
      fleeing = true;
    }
    if (rand.nextInt(300) == 0) {
      fleeing = true;
    }
    if (fleeing) {
      if (FlyToNextTree()) {
        fleeing = false;
      }
      int ai[] = ReturnNearestMaterialCoord(this, Material.leaves, Double.valueOf(16D));
      if (ai[0] == -1) {
        for (int i = 0; i < 2; i++) {
          WingFlap();
        }

        fleeing = false;
      }
      if (rand.nextInt(50) == 0) {
        fleeing = false;
      }
    }
  }
Exemplo n.º 3
0
 public void moveEntityWithHeading(float par1, float par2) {
   super.moveEntityWithHeading((float) motionX, (float) motionZ);
   // moveEntity(motionX, motionY, motionZ);
 }
Exemplo n.º 4
0
 protected void fall(float f) {
   if (!this.isInWater()) {
     super.fall(f);
   }
 }
Exemplo n.º 5
0
  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));
          }
        }
      }
    }
  }