Exemple #1
0
  /** Populate a single chunk if needed. */
  private void populateChunk(int x, int z, boolean force) {
    GlowChunk chunk = getChunk(x, z);
    // cancel out if it's already populated
    if (chunk.isPopulated()) {
      return;
    }

    // cancel out if the 3x3 around it isn't available
    for (int x2 = x - 1; x2 <= x + 1; ++x2) {
      for (int z2 = z - 1; z2 <= z + 1; ++z2) {
        if (!getChunk(x2, z2).isLoaded() && (!force || !loadChunk(x2, z2, true))) {
          return;
        }
      }
    }

    // it might have loaded since before, so check again that it's not already populated
    if (chunk.isPopulated()) {
      return;
    }
    chunk.setPopulated(true);

    Random random = new Random(world.getSeed());
    long xRand = random.nextLong() / 2 * 2 + 1;
    long zRand = random.nextLong() / 2 * 2 + 1;
    random.setSeed((long) x * xRand + (long) z * zRand ^ world.getSeed());

    for (BlockPopulator p : world.getPopulators()) {
      p.populate(world, random, chunk);
    }

    EventFactory.callEvent(new ChunkPopulateEvent(chunk));
  }
  public void getChunkAt(IChunkProvider ichunkprovider, int i, int j) {
    Chunk chunk = this.getOrCreateChunk(i, j);

    if (!chunk.done) {
      chunk.done = true;
      if (this.chunkProvider != null) {
        this.chunkProvider.getChunkAt(ichunkprovider, i, j);

        // CraftBukkit start
        BlockSand.instaFall = true;
        Random random = new Random();
        random.setSeed(world.getSeed());
        long xRand = random.nextLong() / 2L * 2L + 1L;
        long zRand = random.nextLong() / 2L * 2L + 1L;
        random.setSeed((long) i * xRand + (long) j * zRand ^ world.getSeed());

        org.bukkit.World world = this.world.getWorld();
        if (world != null) {
          for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) {
            populator.populate(world, random, chunk.bukkitChunk);
          }
        }
        BlockSand.instaFall = false;
        this.world
            .getServer()
            .getPluginManager()
            .callEvent(new org.bukkit.event.world.ChunkPopulateEvent(chunk.bukkitChunk));
        // CraftBukkit end

        chunk.e();
      }
    }
  }
 private void populateOnGround(World world, Random random, Chunk chunk) {
   for (BlockPopulator populator : onGroundPopulators) {
     populator.populate(world, random, chunk);
   }
 }