Exemplo n.º 1
0
  public void a() {
    this.a.pitch = 0.0F;
    if (this.d) {
      this.d = false;
      double d0 = this.e - this.a.locX;
      double d1 = this.f - (this.a.locY + (double) this.a.getHeadHeight());
      double d2 = this.g - this.a.locZ;
      double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2);
      // CraftBukkit start - Math -> TrigMath
      float f = (float) (TrigMath.atan2(d2, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
      float f1 = (float) (-(TrigMath.atan2(d1, d3) * 180.0D / 3.1415927410125732D));
      // CraftBukkit end

      this.a.pitch = this.a(this.a.pitch, f1, this.c);
      this.a.as = this.a(this.a.as, f, this.b);
    } else {
      this.a.as = this.a(this.a.as, this.a.aq, 10.0F);
    }

    float f2 = MathHelper.g(this.a.as - this.a.aq);

    if (!this.a.getNavigation().f()) {
      if (f2 < -75.0F) {
        this.a.as = this.a.aq - 75.0F;
      }

      if (f2 > 75.0F) {
        this.a.as = this.a.aq + 75.0F;
      }
    }
  }
Exemplo n.º 2
0
  public void l_() {
    super.l_();
    if (!this.world.isStatic) {
      int i = this.aU();

      if (i > 0) {
        if (this.aw <= 0) {
          this.aw = 20 * (30 - i);
        }

        --this.aw;
        if (this.aw <= 0) {
          this.m(i - 1);
        }
      }

      for (int j = 0; j < 5; ++j) {
        ItemStack itemstack = this.g[j];
        ItemStack itemstack1 = this.getEquipment(j);

        if (!ItemStack.matches(itemstack1, itemstack)) {
          ((WorldServer) this.world)
              .getTracker()
              .a((Entity) this, (Packet) (new Packet5EntityEquipment(this.id, j, itemstack1)));
          if (itemstack != null) {
            this.d.a(itemstack.D());
          }

          if (itemstack1 != null) {
            this.d.b(itemstack1.D());
          }

          this.g[j] = itemstack1 == null ? null : itemstack1.cloneItemStack();
        }
      }
    }

    this.c();
    double d0 = this.locX - this.lastX;
    double d1 = this.locZ - this.lastZ;
    float f = (float) (d0 * d0 + d1 * d1);
    float f1 = this.aN;
    float f2 = 0.0F;

    this.aW = this.aX;
    float f3 = 0.0F;

    if (f > 0.0025000002F) {
      f3 = 1.0F;
      f2 = (float) Math.sqrt((double) f) * 3.0F;
      // CraftBukkit - Math -> TrigMath
      f1 = (float) org.bukkit.craftbukkit.TrigMath.atan2(d1, d0) * 180.0F / 3.1415927F - 90.0F;
    }

    if (this.aE > 0.0F) {
      f1 = this.yaw;
    }

    if (!this.onGround) {
      f3 = 0.0F;
    }

    this.aX += (f3 - this.aX) * 0.3F;
    this.world.methodProfiler.a("headTurn");
    f2 = this.f(f1, f2);
    this.world.methodProfiler.b();
    this.world.methodProfiler.a("rangeChecks");

    while (this.yaw - this.lastYaw < -180.0F) {
      this.lastYaw -= 360.0F;
    }

    while (this.yaw - this.lastYaw >= 180.0F) {
      this.lastYaw += 360.0F;
    }

    while (this.aN - this.aO < -180.0F) {
      this.aO -= 360.0F;
    }

    while (this.aN - this.aO >= 180.0F) {
      this.aO += 360.0F;
    }

    while (this.pitch - this.lastPitch < -180.0F) {
      this.lastPitch -= 360.0F;
    }

    while (this.pitch - this.lastPitch >= 180.0F) {
      this.lastPitch += 360.0F;
    }

    while (this.aP - this.aQ < -180.0F) {
      this.aQ -= 360.0F;
    }

    while (this.aP - this.aQ >= 180.0F) {
      this.aQ += 360.0F;
    }

    this.world.methodProfiler.b();
    this.aY += f2;
  }