The always up-to-date definitive guide to terrain generation: Part 6: Gen id's

Discussion in 'Resources' started by jtjj222, Sep 13, 2012.

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


    Part one
    Part Two
    Part Three
    Part Four
    Part Five
    Part Seven

    I haven't written a tutorial in a while, so I decided to write a small one about gen id's while I'm working on the next one. Gen id's are the string attached to the end of the generator name when you specify a world generator. BananaGen by Nightgunner5 uses gen id's heavily. For example, to use BananaGen's mountain generator, I would use the following as the generator name:
    Ok, now that we have that cleared up, let's get to some code, shall we?

    Remember in the first tutorial, in the main plugin file, we made a method called getDefaultWorldGenerator(String,String)? Here, let's refresh your memory:
    3. public ChunkGenerator getDefaultWorldGenerator(String worldName, String GenId) {
    4. return new chunkGenerator();
    5. }

    Bukkit kindly passes the world name and gen id to you in this function, so you can check it, and return the appropriate world generator:
    3. public ChunkGenerator getDefaultWorldGenerator(String worldName, String genId) {
    4. if (genId.equalsIgnoreCase("Mountain")) return new MountainGenerator();
    5. else if (genId.equalsIgnoreCase("Desert")) return new DesertGenerator();
    6. else {
    7. getLogger().log(Level.SEVERE, "Could not find generator id " + genId);
    8. return new chunkGenerator();
    9. }
    10. }

    This was a short tutorial, but gen id's are a feature that isn't used enough. You can also use it to specify values such as scale, smoothing and whatnot. Anyway, this concludes this installment in the series, and stay tuned, because the next few tutorials will be, in no particular order, biomes, other types of nosie (diamond square, voronoi, etc...) and .schematics. So until next time, happy coding!
    mactso and chasechocolate like this.
  2. Offline


    How do I make it so that say, I want to spawn a giant cluster of blocks in a small area with a very small chance of the cluster actually spawning. How would I go about that?
  3. Offline


  4. Offline


    Okay. So when you're generating the terrain. I want everything to be the regular minecraft terrain except occasionally, I want a large cluster of blocks to spawn over 12 chunks or so. How would I do that?
  5. Offline


    You would probably have to hook the world_init event, then add a block populator to the world (world.getBlockPopualators.add() I think) to do whatever it was you wanted to do.
Thread Status:
Not open for further replies.

Share This Page