1.15.2 Custom area generation

Discussion in 'Spigot Plugin Development' started by Yeowza, Feb 10, 2020.

  1. Hello, I was looking into chunkgenerator but it seems to only be for whole world generation. Is there a way to generate a small area (like 100 x 100) and not the whole world?
     
  2. Code (Text):
    for (x in startX to endX) {
        for (y in startY to endY) {
            for (z in startZ to endZ) {
                world.getBlockAt(x,y,z).setType(<whatever you want to put here>);
           }
        }
    }
     
  3. Thanks Schottky, yeah I was thinking about creating my own version but it seems like a lot of work. Was hoping there was a way to use the chunkgenerator to copy the materials it makes.

    I guess another way would be to copy the materials from a separate region and then replace them in the areas I need.
     
  4. Oooh you still want to create a „natural“ world. Well, there‘s certainly ways to make this work but I‘m unsure if there‘s one without NMS...
     
  5. it was easier than I thought xD

    So from this, https://bukkit.gamepedia.com/Developing_a_World_Generator_Plugin, you just have to grab the chunkdata it returns and iterate over it like so..

    Code (Text):
            Generator g = new Generator();
            ChunkData cd = g.generateChunkData(Bukkit.getWorld("my_world"), null, 0, 0, null);
           
            for (int x = 0; x < 16; x++) {
                for (int z = 0; z < 16; z++) {
                    for (int y = 0; y < 200; y++) {
                        Bukkit.getWorld("my_world").getBlockAt(x, y, z).setType(cd.getType(x, y, z));
                    }
                }
            }
    Only issue I forsee is getting the populators like trees, mobs, etc etc.. but I guess I can just add all of that in later. Still feels like there should be an easier way though. :unsure: