Generate a single chunk in empty world

Discussion in 'Plugin Development' started by kaskoepoes112, Feb 15, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    kaskoepoes112

    Hey guys and girls,

    I'm trying to generate a single 16x16 chunk in a empty (void) world.

    I thought about doing something like this:

    Code:
       @Override
        public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome) {
            if (x == 0 && z == 0) {
                // generate chunk using default generator
            }
    
            return createChunkData(world);
        }
    The idea is that I generate a normal chunk at x=0, z=0 and leave the rest of the world empty. However, I have not yet found a way to ge tthe default chunk generator.

    It is mandatory that I use the default generator for the chunk, a custom generator won't work.

    Is there any way to do this? Maybe a little workaround?
     
  2. Offline

    caderapee

    @kaskoepoes112

    This create an empty world from a flat world

    Code:
    @Override
        public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome) {
            ChunkData chunk = createChunkData(world);
         
         
            for (int X = 0; X < 16; X++) {
                for (int Z = 0; Z < 16; Z++) {
                    for (int y = 0; y <= 5; y++) {
                        chunk.setBlock(X, y, Z, Material.AIR);
                    }
                }
            }
         
            return chunk;
        }
     
  3. Offline

    MCMastery

    You can't get the default world generator. I think the easiest way to do this is have a "source" world that you copy the chunk from
     
Thread Status:
Not open for further replies.

Share This Page