コード例 #1
0
ファイル: EntityPlayerMP.java プロジェクト: Tux2/CanaryRecode
  public void g() {
    try {
      super.l_();

      for (int i0 = 0; i0 < this.bK.j_(); ++i0) {
        ItemStack itemstack = this.bK.a(i0);

        if (itemstack != null && Item.f[itemstack.c].f() && this.a.e() <= 5) {
          Packet packet = ((ItemMapBase) Item.f[itemstack.c]).c(itemstack, this.q, this);

          if (packet != null) {
            this.a.b(packet);
          }
        }
      }

      // CanaryMod: HealthChange / HealthEnabled
      if (this.aX() != this.cm && cm != -99999999 && this.getPlayer() != null) {
        // updates your health when it is changed.
        if (!Configuration.getWorldConfig(getCanaryWorld().getFqName()).isHealthEnabled()) {
          super.b(this.aW());
          this.M = false;
        } else {
          HealthChangeHook hook = new HealthChangeHook(getPlayer(), cm, this.aX());

          Canary.hooks().callHook(hook);
          if (hook.isCanceled()) {
            super.b(this.cm);
          }
        }
      }
      //

      if (this.aX() != this.cm || this.cn != this.bN.a() || this.bN.e() == 0.0F != this.co) {
        // CanaryMod: convert health for values above 20
        int health = (int) (this.aX() / (this.aW() / 20));

        health = (this.aX() > 0 && health == 0) ? 1 : health;
        this.a.b(new Packet8UpdateHealth(health, this.bN.a(), this.bN.e()));
        //
        this.cm = this.aX();
        this.cn = this.bN.a();
        this.co = this.bN.e() == 0.0F;
      }

      if (this.cg != this.cp) {
        // CanaryMod: ExperienceHook / ExperienceEnabled
        if (!Configuration.getWorldConfig(getCanaryWorld().getFqName()).isExperienceEnabled()) {
          this.cg = 0;
          this.cf = 0;
        } else if (getPlayer() != null) { // NPC?
          ExperienceHook hook = new ExperienceHook(getPlayer(), this.cp, cg);

          if (!hook.isCanceled()) {
            this.cp = this.cg;
            this.a.b(new Packet43Experience(this.ch, this.cg, this.cf));
          }
        }
        //
      }
    } catch (Throwable throwable) {
      CrashReport crashreport = CrashReport.a(throwable, "Ticking player");
      CrashReportCategory crashreportcategory = crashreport.a("Player being ticked");

      this.a(crashreportcategory);
      throw new ReportedException(crashreport);
    }
  }