public void b(int i, int j) {
    if (this.h.t.e()) {
      OChunkCoordinates ochunkcoordinates = this.h.I();
      int k = i * 16 + 8 - ochunkcoordinates.a;
      int l = j * 16 + 8 - ochunkcoordinates.c;
      short short1 = 128;

      if (k < -short1 || k > short1 || l < -short1 || l > short1) {
        this.b.add(Long.valueOf(OChunkCoordIntPair.a(i, j)));
      }
    } else {
      this.b.add(Long.valueOf(OChunkCoordIntPair.a(i, j)));
    }
  }
  public OChunk regenerateChunk(int i, int j) {
    Long chunkCoordIntPair = OChunkCoordIntPair.a(i, j);

    // Unloading the chunk
    OChunk unloadedChunk = (OChunk) f.a(chunkCoordIntPair.longValue());

    if (unloadedChunk != null) {
      unloadedChunk.e(); // setChunkModified
      b(unloadedChunk); // saveChunkData
      a(unloadedChunk); // saveChunkExtraData
      b.remove(chunkCoordIntPair); // droppedChunksSet
      f.d(chunkCoordIntPair.longValue()); // id2ChunkMap.remove
      g.remove(unloadedChunk); // loadedChunks
    }

    // Generating the new chunk
    OChunk newChunk = d.d(i, j);

    f.a(chunkCoordIntPair, newChunk);
    g.add(newChunk);
    if (newChunk != null) {
      newChunk.c(); // onChunkLoad
      newChunk.d(); // onChunkUnload
    }
    newChunk.a(this, this, i, j); // populateChunk

    // Save the new chunk, overriding the old one
    a(newChunk);
    b(newChunk);
    newChunk.k = false;
    if (e != null) {
      e.b(); // saveExtraData
    }

    return newChunk;
  }
  public OChunk c(int i, int j) {
    long k = OChunkCoordIntPair.a(i, j);

    this.b.remove(Long.valueOf(k));
    OChunk ochunk = (OChunk) this.f.a(k);

    if (ochunk == null) {
      // CanaryMod: load preload plugins once!
      if (!loadedpreload) {
        etc.getLoader().loadPreloadPlugins();
        loadedpreload = true;
      }
      ochunk = this.f(i, j);
      if (ochunk == null) {
        // Canary onChunkCreate hook
        byte[] blocks =
            (byte[]) etc.getLoader().callHook(PluginLoader.Hook.CHUNK_CREATE, i, j, h.world);

        if (blocks != null) {
          ochunk = Chunk.getNewChunk(h, blocks, i, j).chunk;
          ochunk.k = true; // is populated = true
          ochunk.b(); // lighting update
        } else if (this.d == null) {
          ochunk = this.c;
        } else {
          try {
            ochunk = this.d.d(i, j);
          } catch (Throwable throwable) {
            OCrashReport ocrashreport = OCrashReport.a(throwable, "Exception generating new chunk");
            OCrashReportCategory ocrashreportcategory = ocrashreport.a("Chunk to be generated");

            ocrashreportcategory.a(
                "Location",
                String.format("%d,%d", new Object[] {Integer.valueOf(i), Integer.valueOf(j)}));
            ocrashreportcategory.a("Position hash", Long.valueOf(k));
            ocrashreportcategory.a("Generator", this.d.d());
            throw new OReportedException(ocrashreport);
          }
        }

        etc.getLoader().callHook(PluginLoader.Hook.CHUNK_CREATED, ochunk.chunk);
      }

      this.f.a(k, ochunk);
      this.g.add(ochunk);
      if (ochunk != null) {
        ochunk.c();
        // Canary onChunkLoaded hook
        etc.getLoader().callHook(PluginLoader.Hook.CHUNK_LOADED, ochunk.chunk);
        if (!ochunk.k && this.a(i + 1, j + 1) && this.a(i, j + 1) && this.a(i + 1, j)) {
          this.a(this, i, j);
        }
      } // To prevent NullPointerExceptions
      if (this.a(i - 1, j)
          && !this.d(i - 1, j).k
          && this.a(i - 1, j + 1)
          && this.a(i, j + 1)
          && this.a(i - 1, j)) {
        this.a(this, i - 1, j);
      }

      ochunk.a(this, this, i, j);
    }

    return ochunk;
  }
 public boolean a(int i, int j) {
   return this.f.b(OChunkCoordIntPair.a(i, j));
 }
  public OChunk d(int i, int j) {
    OChunk ochunk = (OChunk) this.f.a(OChunkCoordIntPair.a(i, j));

    return ochunk == null ? (!this.h.y && !this.a ? this.c : this.c(i, j)) : ochunk;
  }
示例#6
0
  public void a(boolean var1) {
    super.F_();

    for (int var2 = 0; var2 < this.k.c(); ++var2) {
      OItemStack var3 = this.k.g_(var2);
      if (var3 != null && OItem.d[var3.c].t_() && this.a.b() <= 2) {
        OPacket var4 = ((OItemMapBase) OItem.d[var3.c]).c(var3, this.bi, this);
        if (var4 != null) {
          this.a.b(var4);
        }
      }
    }

    if (var1 && !this.f.isEmpty()) {
      OChunkCoordIntPair var14 = (OChunkCoordIntPair) this.f.get(0);
      double var5 = var14.a(this);

      for (int var7 = 0; var7 < this.f.size(); ++var7) {
        OChunkCoordIntPair var8 = (OChunkCoordIntPair) this.f.get(var7);
        double var9 = var8.a(this);
        if (var9 < var5) {
          var14 = var8;
          var5 = var9;
        }
      }

      if (var14 != null) {
        boolean var17 = false;
        if (this.a.b() < 4) {
          var17 = true;
        }

        if (var17) {
          OWorldServer var18 = (OWorldServer) getDimension().getHandle(); // this.b.a(this.w);
          if (var18.i(var14.a << 4, 0, var14.b << 4)) {
            OChunk var11 = var18.d(var14.a, var14.b);
            if (var11.k) {
              this.f.remove(var14);
              this.a.b((new OPacket51MapChunk(var18.d(var14.a, var14.b), true, 0)));
              List var12 =
                  var18.c(var14.a * 16, 0, var14.b * 16, var14.a * 16 + 16, 256, var14.b * 16 + 16);

              for (int var13 = 0; var13 < var12.size(); ++var13) {
                this.a((OTileEntity) var12.get(var13));
              }
            }
          }
        }
      }
    }

    if (this.J) {
      if (this.m != this.l) {
        this.F();
      }

      if (this.bh != null) {
        this.b(this.bh);
      } else {
        this.K += 0.0125F;
        if (this.K >= 1.0F) {
          this.K = 1.0F;
          this.I = 10;
          boolean var15 = false;
          byte var16;
          if (this.w == -1) {
            var16 = 0;
          } else {
            var16 = -1;
          }
          Location location = getPlayer().getLocation();
          int currDim = getPlayer().getDimension().getType().getId();
          location.setDimensionId(currDim == 0 ? -1 : 0);
          CancelableHook hook =
              (CancelableHook)
                  Canary.hooks().callCancelableHook(new TeleportHook(getPlayer(), location, true));
          if (!hook.isCanceled()) {
            this.b.h.switchDimension(this, var16, true);
            this.ci = -1;
            this.cf = -1;
            this.cg = -1;
            this.a(OAchievementList.x);
          }
        }
      }

      this.J = false;
    } else {
      if (this.K > 0.0F) {
        this.K -= 0.05F;
      }

      if (this.K < 0.0F) {
        this.K = 0.0F;
      }
    }

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

    if (this.ap != this.cf) {
      // Check if health is enabled
      if (!Configuration.getWorldConfig(bi.getCanaryDimension().getName()).isHealthEnabled()) {
        ap = 20;
        az = false;
      } else {
        // Call hook
        // CancelableHook hook = Canary.hooks().callCancelableHook(new HealthChangeHook());
        // if(hook.isCancelled){
        //  ap = cf;
        // }
      }
    }

    if (this.aD() != this.cf
        || this.cg != this.foodStats.getFoodLevel()
        || this.foodStats.getFoodSaturationLevel() == 0.0F != this.ch) {
      this.a.b(
          (new OPacket8UpdateHealth(
              this.aD(), this.foodStats.getFoodLevel(), this.foodStats.getFoodSaturationLevel())));
      this.cf = this.aD();
      this.cg = this.foodStats.getFoodLevel();
      this.ch = this.foodStats.getFoodSaturationLevel() == 0.0F;
    }

    // CanaryMod start - Experience Update
    if (this.N != this.ci) {
      if (!Configuration.getWorldConfig(bi.getCanaryDimension().getName())
          .isExperienceEnabled()) { // CanaryMod - check if Experience is enabled
        N = 0;
        M = 0;
      } else { // Call hook
        CancelableHook hook =
            (CancelableHook)
                Canary.hooks().callCancelableHook(new ExperienceHook(canaryPlayer, ci, N));
        if (hook.isCanceled()) {
          N = ci;
        }
      }
    }

    if (this.N != this.ci) {
      this.ci = this.N;
      this.a.b((new OPacket43Experience(this.O, this.N, this.M)));
    }
  }