Search in sources :

Example 1 with ChunkWrapper

use of com.plotsquared.core.location.ChunkWrapper in project PlotSquared by IntellectualSites.

the class BukkitPlotGenerator method generateChunkData.

@Override
@NonNull
public ChunkData generateChunkData(@NonNull World world, @NonNull Random random, int x, int z, @NonNull BiomeGrid biome) {
    int minY = BukkitWorld.getMinWorldHeight(world);
    int maxY = BukkitWorld.getMaxWorldHeight(world);
    GenChunk result = new GenChunk(minY, maxY);
    if (this.getPlotGenerator() instanceof SingleWorldGenerator) {
        if (result.getChunkData() != null) {
            for (int chunkX = 0; chunkX < 16; chunkX++) {
                for (int chunkZ = 0; chunkZ < 16; chunkZ++) {
                    for (int y = minY; y < maxY; y++) {
                        biome.setBiome(chunkX, y, chunkZ, Biome.PLAINS);
                    }
                }
            }
            return result.getChunkData();
        }
    }
    // Set the chunk location
    result.setChunk(new ChunkWrapper(world.getName(), x, z));
    // Set the result data
    result.setChunkData(createChunkData(world));
    result.biomeGrid = biome;
    result.result = null;
    // Catch any exceptions (as exceptions usually thrown)
    try {
        // Fill the result data if necessary
        if (this.platformGenerator != this) {
            return this.platformGenerator.generateChunkData(world, random, x, z, biome);
        } else {
            generate(BlockVector2.at(x, z), world, result);
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }
    // Return the result data
    return result.getChunkData();
}
Also used : GenChunk(com.plotsquared.bukkit.queue.GenChunk) SingleWorldGenerator(com.plotsquared.core.generator.SingleWorldGenerator) ChunkWrapper(com.plotsquared.core.location.ChunkWrapper) NonNull(org.checkerframework.checker.nullness.qual.NonNull)

Example 2 with ChunkWrapper

use of com.plotsquared.core.location.ChunkWrapper in project PlotSquared by IntellectualSites.

the class BlockStatePopulator method populate.

@Override
public void populate(@NonNull final World world, @NonNull final Random random, @NonNull final Chunk source) {
    if (this.queue == null) {
        this.queue = PlotSquared.platform().globalBlockQueue().getNewQueue(new BukkitWorld(world));
    }
    final PlotArea area = this.plotAreaManager.getPlotArea(world.getName(), null);
    if (area == null) {
        return;
    }
    final ChunkWrapper wrap = new ChunkWrapper(area.getWorldName(), source.getX(), source.getZ());
    final ScopedQueueCoordinator chunk = this.queue.getForChunk(wrap.x, wrap.z, com.plotsquared.bukkit.util.BukkitWorld.getMinWorldHeight(world), com.plotsquared.bukkit.util.BukkitWorld.getMaxWorldHeight(world) - 1);
    if (this.plotGenerator.populateChunk(chunk, area)) {
        this.queue.enqueue();
    }
}
Also used : PlotArea(com.plotsquared.core.plot.PlotArea) BukkitWorld(com.sk89q.worldedit.bukkit.BukkitWorld) ChunkWrapper(com.plotsquared.core.location.ChunkWrapper) ScopedQueueCoordinator(com.plotsquared.core.queue.ScopedQueueCoordinator)

Aggregations

ChunkWrapper (com.plotsquared.core.location.ChunkWrapper)2 GenChunk (com.plotsquared.bukkit.queue.GenChunk)1 SingleWorldGenerator (com.plotsquared.core.generator.SingleWorldGenerator)1 PlotArea (com.plotsquared.core.plot.PlotArea)1 ScopedQueueCoordinator (com.plotsquared.core.queue.ScopedQueueCoordinator)1 BukkitWorld (com.sk89q.worldedit.bukkit.BukkitWorld)1 NonNull (org.checkerframework.checker.nullness.qual.NonNull)1