ChunkGenerators & BlockPopulators FAQ

Discussion in 'Plugin Development' started by Dinnerbone, Jun 23, 2011.

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

    Dinnerbone Bukkit Team Member

    Recently I added a whole new section of API to Bukkit; Custom ChunkGenerators and BlockPopulators. I've had a world (sorry) of questions so I'll try to answer as many as I can here.

    What the hell is a ChunkGenerator?
    It's a thing. It lets you design new landscapes for a world. Plugins can create one and assign it to a world, and all new chunks created by the world will have been designed and created by that ChunkGenerator.

    Okay, and what's a BlockPopulator?
    BlockPopulators are the things that go over a new chunk and fill it in with the details. In vanilla minecraft, they're used to make all sorts of things likes dungeons, lakes, trees and grass.

    Do you have an example of these?
    Check out my example plugin BukkitFullOfMoon (jar). Type "/moon" when you're ingame and see!

    Can I override the default worlds?
    Yes! But it's not as easy as making your own. Specifically, you need to:
    • Add load: startup to your plugin.yml. You need this to make sure your plugin loads before the worlds do.
    • Add a new method to your plugin called getDefaultWorldGenerator(String worldName, String id). It should return the ChunkGenerator associated with the given id (if any id is specified). See here for an example.
    • Tell your users to add the following lines to their bukkit.yml:
      Code:
      worlds:
           NAME_OF_THEIR_WORLD:
             generator: NAME_OF_YOUR_PLUGIN:ID_OF_GEN
    • ID is optional, it can be left out (so just use "NAME_OF_YOURPLUGIN" and no colon). It's up to you if you want to use an ID, but they're pretty much required if you have multiple possible generators and people need a certain one.
    Can I make a world with another plugin's generator?
    Yes! You will need the name of the plugin, the name of the world and an ID (or null). If you're getting this from a user, I'd highly recommend keeping it with the same format as bukkit.yml ("SomePlugin" or "SomePlugin:SuperGenerator").

    Simply get the plugin with the given name, make sure it actually exists, and then call its getDefaultWorldGenerator(worldName, id) method.

    Can I add a BlockPopulator to someone elses ChunkGenerator?
    Yep! It's a simple world.getPopulators().addPopulator(populator).

    Can I add vanilla BlockPopulators to my own ChunkGenerator?
    Not yet. We're working on it.



    Please feel free to ask any questions you may have and I will try to answer them the best I can :)
     
    ChipDev, kmunBiene, _Error and 10 others like this.
  2. Offline

    WinSock

    Epic, now just push out the RB ;)
     
    glen3b, caldabeast and robotmlg like this.
  3. Offline

    robinjam

    This is pretty exciting stuff. Can't wait to see what the Bukkit community does with it.
     
  4. Offline

    Niles

    This looks really cool. but the latest successful build returns no such command for '/moon' (#925)
     
  5. Offline

    Dinnerbone Bukkit Team Member

    Are you using the plugin? Please give me a copy of "/version" and "/plugins"
     
  6. Offline

    Niles

    oops. sorry. I didnt realise it was a plugin.
     
  7. Offline

    Kazinsal

    Neat. Will it be possible to build a world generator that acts like a scaled up (in continent and ocean sizes) version of the vanilla generator? Us Cordiloners were rather disappointed with the small sizes of continents and oceans in Beta's generators.
     
  8. Offline

    Niles

    ehm, ant fails with several javac errors. wait I'll paste the output somewhere.
     
  9. Offline

    codename_B

    Gonmarte likes this.
  10. Offline

    Niles

    I couldnt fit it so I started a new terminal and did an cmd+A so NO I did not get to choose my username. http://pastie.org/2113512

    java version "1.6.0_26"
    Java(TM) SE Runtime Environment (build 1.6.0_26-b03-378-11A486)
    Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02-378, mixed mode)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
  11. Offline

    Dinnerbone Bukkit Team Member

    It looks like it's missing the Bukkit import. I compile with maven (as recommended), so I'm of little help :(
     
  12. Offline

    Niles

    oh ok, I didnt know what to do so I asked someone else and they said ant.
     
  13. Offline

    Dinnerbone Bukkit Team Member

  14. Offline

    Kazinsal

  15. Offline

    Dinnerbone Bukkit Team Member

    You can create those. It just needs some work getting them tuned right :)
     
  16. Offline

    codename_B

    Check out V2 - it has caves, resources, and epic dungeons!
    Lava and underground lakes are on the way in v3, but seriously, you ought to check out those caves :D
     
  17. Offline

    anonymous

    Can you post a picture of what the moon thing looks like? I can't test it atm.
     
  18. Offline

    Niles

    neither can I, all it does for me is take 30 mins to prepare the spawn arean to 32% than crashes.
     
  19. Offline

    Dinnerbone Bukkit Team Member

    Please define "crashes" so that we can fix it.
     
  20. Offline

    Niles

    ehm, I kill it because its eating up cpu and ram and is dropping player connections, freezing and not being a minecraft server.
     
  21. Offline

    Pandarr

    Here is one that I've been working on a bit here and there for a few days: https://github.com/Pandarr/PandaGen

    It creates landscapish stuff. Still need to work on smoothing it out. Heck I'm pretty sure some of the code is even wrong. Quite aware it needs work still... :)

    Once you are in game type /pandagen to get teleported. I have entity spawning turned off in the world and it always uses seed "1" as I'm trying to see what my changes do. You can remove the 1 for random worlds though.

    [​IMG]
     
  22. Offline

    formivore

    Hi, I'm a minecraft modder who wants to port my world generation mod into a bukkit plugin. So I need to do something very simple, which is add a populator to the default list so the default world is populated with my creations.

    EDIT - better way to do this
    Code:
    public void onEnable(){
            PluginManager pm = this.getServer().getPluginManager();
            pm.registerEvent(Event.Type.WORLD_INIT, new WorldListener(){
                public void onWorldInit(WorldInitEvent event) {
                    event.getWorld().getPopulators().add(new MyPopulator());
                }
            }, Event.Priority.Normal, this);
        }
    Not sure there is an addPopulators() method as stated in OP. getPopulators() just returns a list.
     
    dadaemon likes this.
  23. Offline

    Dinnerbone Bukkit Team Member

    Hook the WORLD_INIT event and add your populator if the world meets your requirements (environment type etc) :)
     
    4am likes this.
  24. Offline

    formivore

    Oh I see. Thanks!
     
  25. Offline

    xpansive

    Here's a screenshot of the moon world:
    [​IMG]

    This is probably a kinda stupid question, but when compiling with maven, I get a bunch of errors about the ChunkGenerator and BlockPopulator classes not existing. Do I need to have my bukkit.jar somewhere so it uses it in the classpath?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
  26. Offline

    Dinnerbone Bukkit Team Member

    Redownload the maven dependencies
     
  27. Offline

    xpansive

    *yay* Now to start working on my generator :D

    Edit: heh, this one's sure to confuse you:
    "But I'm sure I built my house here..."
    [​IMG]

    Edit 2: Another one, this time with voronoi noise:
    [​IMG]
     
    TheDevZone and Mixerman123 like this.
  28. Offline

    RawCode

    How to return back to initial chunk generator (eg. what class used to generate chunks initially)
     
  29. Offline

    Dinnerbone Bukkit Team Member

    world.getGenerator()
     
    Tim Visee likes this.
  30. Offline

    codename_B

    I'm a huge fan of #2.

    Let me know when you have cavegens working, I'd love to see them!
     
Thread Status:
Not open for further replies.

Share This Page