[Basic] Creating custom world generators

Discussion in 'Resources' started by codename_B, Jul 4, 2011.

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


    This is a quick tutorial about how to use ChunkGenerator to write your own custom map gens;
    It will be aimed at the very basic generation level, assuming you know how to define packages and import the relevant classes.
    What I won't do is explain how to do seamless chunk generation - as I'm not 100% sure myself - you're better off checking out other peoples source in order to see how they do it.
    My way of getting around the issue was to generate huge areas of terrain in "memory" (as a heightmap) - this is a fairly efficient way of doing things, but you still have to generate the heightmap.

    If you're looking for some javadocs, you'll find them here.

    Anyway, on with lesson 1.
    public class GenerateNothing extends ChunkGenerator {
        //This is where you stick your populators - these will be covered in another tutorial
        public List<BlockPopulator> getDefaultPopulators(World world) {
            return Arrays.asList((BlockPopulator) new BlankPopulator());
        //This needs to be set to return true to override minecraft's default behaviour
        public boolean canSpawn(World world, int x, int z) {
            return true;
        //This converts relative chunk locations to bytes that can be written to the chunk
        public int xyzToByte(int x, int y, int z) {
        return (x * 16 + z) * 128 + y;
        public byte[] generate(World world, Random rand, int chunkx, int chunkz) {
        result = new byte[32768];
        int y = 0;
        //This will set the floor of each chunk at bedrock level to bedrock
        for(int x=0; x<16; x++){
        for(int z=0; z<16; z++) {
        result[xyzToByte(x,y,z)] = (byte) Material.BEDROCK.getId();
        return result;
    This will create a 1 layer thin layer of bedrock flatmap - please don't use it as-is for a plugin, add new stuff before you release anything. Consider yourself warned :p

    Lesson 2 - actually getting the bloody thing to work.
    Have this method in your main class

    public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
            return new GenerateNothing();
    then add this code to bukkit.yml

             generator: YourPluginName
    Damocles, Plo124, DeMaggo and 3 others like this.
  2. Offline



    I say this mode is [Basic] mode because it uses easy codes.

    No more transferring SSP flat maps, finally!
  3. Offline


    Changed the title to [Basic] - done :) thanks for the feedback.
  4. Offline


    Your welcome! I saw the [Basic] before you quoted it.
  5. Offline


    Is it possible to add custom populators to minecraft's default chunk generator?
  6. Offline


    I've never tried. I assume it would be possible.
  7. Offline


    dylanisawesome1 likes this.
  8. Offline


    I'm puzzled about this part:

    new BlankPopulator());
    am I supposed to create a new class? D:
  9. Offline


    Only if you want to - that bit can just be removed if you don't want to use any populators.
  10. Offline


    Ah ok I get it now xD I wasn't 100% what you meant with that! Thanks!! :)
  11. Offline


    I can't find anyone who does this. Any suggestions?

  12. Offline


    Seamless terrain generation? Perhaps you should check out the seamless terrain generation tutorial using SimplexOctaves I wrote.
  13. Offline


    I wanted to create a custom map generator because I think the one 1.8 offers is boring.
    Sorry Notch :(

    I've tried your code, but when I load bukkit, it says:
    >> Could not set generator for default world 'world': Plugin 'CT-World' is not enabled yet (is it load:STARTUP?)

    What can I do here?

  14. Offline

    Celtic Minstrel

    Add "load: startup" on a line in your plugin.yml.
  15. Offline


  16. Offline


    This post was amazing and helped me so much. THANK YOU!
  17. Offline


    Bump for awesome ness
  18. Awesome thank you codename_B! You have helped me a lot already.
Thread Status:
Not open for further replies.

Share This Page