ChunkGenerators & BlockPopulators FAQ

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

  1. Offline

    daddychurchill

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Mike, Nice example THX
  2. Offline

    AmoebaMan

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I'm coding a small plugin that basically needs to do two things:
    1. Alter the size and rarity of natural spawning ore veins
    2. Whenever a vein is generated (I assume this is done by a BlockPopulator) retrieve and store the locations of the ore blocks.
    Is there an easy way to do this without writing my own generator from scratch?
  3. Offline

    Celtic Minstrel

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    You can write your own ore BlockPopulator and add it to the default generator. I don't think you can remove the default ore populator, though.
  4. Offline

    Xases

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  5. Offline

    xpansive

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  6. Offline

    FnordianLoop

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    odd this plugin example gives me an error on /moon
    Code:
    10:50:56 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'moon
    ' in plugin BukkitFullOfMoon v0.1.0
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:42)
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:16
    6)
            at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:4
    73)
            at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.
    java:821)
            at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:781)
     
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:764)
            at net.minecraft.server.Packet3Chat.handle(Packet3Chat.java:33)
            at net.minecraft.server.NetworkManager.b(NetworkManager.java:229)
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:113)
            at net.minecraft.server.NetworkListenThread.a(NetworkListenThread.java:7
    8)
            at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:554)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:452)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:490)
    Caused by: java.lang.NoSuchMethodError: org.bukkit.Server.createWorld(Ljava/lang
    /String;Lorg/bukkit/World$Environment;Lorg/bukkit/generator/ChunkGenerator;)Lorg
    /bukkit/World;
            at com.dinnerbone.bukkit.moon.BukkitMoon.getMoon(BukkitMoon.java:38)
            at com.dinnerbone.bukkit.moon.MoonCommandExec.onCommand(MoonCommandExec.
    java:13)
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:40)
            ... 12 more
  7. Offline

    xpansive

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Sorry, I didn't test it... It appears as if it is still using the old world creation methods.
  8. Offline

    FnordianLoop

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    thanks for looking into it xpansive. Dinnerbone, I'd be eternally grateful if you could fix this little snafu.
  9. Offline

    Tim Visee

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Hi thanks for this but I've a problem. I searched on this topic if I could find how to generate mountains in my world generator. What I just want is generate small hills with a heigh difference of 5 or something, so yes really small smooth hills like the flatlands biome in minecraft. I tested the following code (the noice generator with the 'height' variable part);
    PHP:
    private NoiseGenerator generator;
     
        private 
    NoiseGenerator getGenerator(World world) {
            if (
    generator == null) {
                
    generator = new SimplexNoiseGenerator(world);
            }
     
            return 
    generator;
        }
     
        private 
    int getHeight(World worlddouble xdouble yint variance) {
            
    NoiseGenerator gen getGenerator(world);
     
            
    double result gen.noise(xy);
            
    result *= variance;
            return 
    NoiseGenerator.floor(result);
        }
     
    public 
    byte[] generate(World worldRandom randomint cxint cz) {
            
    byte[] result = new byte[32768];
     
            for (
    int x 016x++) {
                for (
    int z 016z++) {
                    
    int height getHeight(worldcx 0.0625cz 0.06252) + 60;
                    for (
    int y 0heighty++) {
                        
    result[(16 z) * 128 y] = (byte)Material.SPONGE.getId();
                    }
                }
            }
     
            return 
    result;
        }
    but this doesn't look really smooth I want to spread it out to make it smoother but when I change some numbers in here;
    PHP:
     int height getHeight(worldcx 0.0625cz 0.06252) + 60;
    it won't work too. Could anyone help me with a explenation for noice generators to generate smooth hills? That would be really cool!
    Thanks in advance,
    Tim Visée
  10. Offline

    Tim Visee

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I already found the solution. You could find the solution here;
    forums.bukkit.org/threads/how-to-generate-smooth-hills-for-my-world-generator.72145
  11. Offline

    daddychurchill

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I have been spinning around a problem that I think is actually buried in Bukkit. Specifically I was working on my CityWorld generator and was getting crazy NULL reference exception that I could not find. Eventually (about four hours later) I traced it down to the returning of certain Biomes via generateBlockSections. It seems that if you return SCRUBLAND eventually a null exception is thrown way down deep in Bukkit.

    From my glancing at the bukkit code via JD, it looks like the following biomes are not "referenced" in CraftBlock.class' static initializer...
    • ICE_DESERT
    • RAINFOREST
    • SAVANNA
    • SEASONAL_FOREST
    • SHRUBLAND
    • TUNDRA

    I might be wrong but not using those biomes definitely make things work better. :)
    I am heading over to post an official bug report but figured I would alert the fellow world generators of the potential issue.

    [BUG - https://bukkit.atlassian.net/browse/BUKKIT-1684]

    This post has been edited 1 time. It was last edited by daddychurchill May 20, 2012.
  12. Offline

    Tim Visee

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Hmm, strange in my world generator (Dungeon Maze, released soon) I didn't have this problem, well I think, not sure. When I really don't have this problem I don't know what happend :(
  13. Offline

    Celtic Minstrel

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    They may be old biomes from before they redid the biome code...
  14. Offline

    daddychurchill

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Based on my conversations with Mike it sounds like that is the case
  15. Offline

    Corgano

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Anyone found a way to do biomes? Notch promised to but only went over noise generators, then jtjj222 teased us with 5 extremely nice tutorials and then got too busy...

    Does ANYONE have the time and know how to do a tutorial on biomes?!?
  16. Offline

    Celtic Minstrel

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    What are you really asking...
  17. Offline

    jtjj222

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Use the biomegrid object to set/get biome data from the chunk generator. Use World.getBlock().getBiome() (I think) from a block populator. I will write up a tutorial later today :D
    deadlock989 likes this.
  18. Offline

    4am

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Been searching for this answer all over - should have started at the source!
  19. Offline

    Splated

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Is there a way to make the world type "The End" with just a ChunkGenerator ?

    Im trying to make the first loaded world The End.
  20. Offline

    Scorpion_vn

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Hi, is it normal that I get a ton of compile errors with 1.5 API?
    There is no Event.Type,
    There is no WorldListener,
    There is no Event.Priority.

    How could one port this snippet to 1.5 API?
    Thanks in advance.

    Well I did it:
    Code:
      public void onEnable(){
            PluginManager pm = this.getServer().getPluginManager();
            pm.registerEvent(WorldInitEvent.class, new Listener (){}, EventPriority.NORMAL, new EventExecutor() {
                public void execute(Listener listener, Event event) throws EventException {
                    WorldInitEvent initEvent = (WorldInitEvent) event;
                    initEvent.getWorld().getPopulators().add(new MyPopulator());
                    getLogger().log(Level.FINEST, "injected MyPopulator");
                }
            }, this);
        }
    

    This post has been edited 3 times. It was last edited by Scorpion_vn Mar 19, 2013.
  21. Offline

    El_Minadero

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Are there any good tutorials out there for customized ore generation using Vanilla terrain generation? jtj222 mentioned something about block populators, but I feel like i need a written tutorial to get it down.
  22. Offline

    jtjj222

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I wrote a tutorial about block popualtors. It was in the plugin tutorials I sent you :p
  23. Offline

    El_Minadero

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    was it? how am i missing all of these. lol
  24. Offline

    Ewe Loon

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    A word of warning, in case no-one has mentioned it

    as of 1.5 the plugin will reload when "/reload all" is called, but the populator isn't reloaed, so stored references to the plugin will become invalid, this is importat, if you need to shedule delated tasks
    Tim Visee likes this.
  25. Offline

    Sebi

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I have a problem with generating terrain, I've looked through the forums but with no results.

    I'm trying to create a generator that, for certain chunks, will use the original generator but for others I want to use my own generator.

    I was thinking of simply doing:
    Code:
    public byte[][] generateBlockSections(World world, Random random, int chunkX, int chunkZ, BiomeGrid biomeGrid) {
            if(...) {
                byte[][] result = new byte[world.getMaxHeight() / 16][];
               ... // generate my own terrain
                return result;
            }else{
                return defaultGenerator.generateBlockSections(world, random, chunkX, chunkZ, biomeGrid); // use default generator
            }
        }
    Where defaultGenerator is ChunkGenerator from the main world (normal generator) but it turns out that getGenerator method executed on world with default chunk generator returns null. Is there a way to pass certain chunks back to the default generator?

    Thanks

    This post has been edited 1 time. It was last edited by TnT May 13, 2013.

Share This Page