Problem with generating world

Discussion in 'Plugin Development' started by IkeVoodoo, Oct 12, 2020.

  1. Offline


    Hello, i am having problems generating a world, first, i am trying to generate the world when something is said (as a test), but it runs on the chat thread, is there a way i could run it on the server thread? also, when generating the world it stops at

    12.10 14:41:06 [Server] Async Chat Thread - #0/INFO Arrow Despawn Rate: 1200 Trident Respawn Rate:1200

    any particular reason? (i don't get any errors, apart when disabling then re enabling the plugin trough plugman wich throws a:

    "12.10 14:50:01 [Server] Async Chat Thread - #2/ERROR Could not pass event AsyncPlayerChatEvent to WorldGeneratorTestPlugin v1.0")

    to generate a world i do:

    WorldCreator c = new WorldCreator(worldName);
    if(seed != null) c.seed(seed.longValue());
    if(chunkGen != null) c.generator(chunkGen);
    generatedWorld = c.createWorld();
    worldName is a string, in this case "TestingWorld"
    type is WorldType.NORMAL
    generateStructures is a boolean set to true
    seed is a "Long" (not long, i used the wrapper class) that is set to null unless set with a method
    chunkGen is a ChunkGenerator (in this case it is set to a custom chunk generator, ill show in a second)
    generatedWorld is to output it
    dimension is Envirioment.NORMAL

    now, for the chunk generator i followed bukkits tutorial page ""

    here is the code:

    SimplexOctaveGenerator generator = new SimplexOctaveGenerator(new Random(world.getSeed()), octaves);
            ChunkData chunk = createChunkData(world);
            for (int X = 0; X < 16; X++)
                for (int Z = 0; Z < 16; Z++) {
                    currentHeight = (int) ((generator.noise(chunkX * 16 + X, chunkZ * 16 + Z, 0.5D, 0.5D, true) + 1) * maxWorldHeight + minWorldHeight);
                    blockGen.generateBlocks(X, Z, currentHeight, world);
    octaves is an int set to 8
    currentHeight is an int set to 50
    minWorldHeight is a double set to 50D
    maxWorldHeight is a double set to 15D
    generatorScale is a double set to 0.005D
    blockGen is the block generator (ill show in a sec)

    also i have a list

    private List<BlockPopulator> populators = new ArrayList<>();

    wich has in it a TreePopulator (explaining this too in a sec)

    the block generator is an interface, with one method:

    public void generateBlocks(int X, int Z, int currentHeight, World world);

    wich i then use to make "MyBlockGenerator" (a test)

    BlockUtils.setBlock(world, X, currentHeight, Z, Material.GRASS);
    BlockUtils.setBlock(world, X, currentHeight - 1, Z, Material.DIRT);
    for (int i = currentHeight - 2; i > 0; i--)
        BlockUtils.setBlock(world, X, i, Z, Material.STONE);
    BlockUtils.setBlock(world, X, 0, Z, Material.BEDROCK);
    Block utils is just a utility class for blocks, when setting a block it does

    world.getBlockAt(new Location(world, posX, posY, posZ)).setType(type);

    when i want to register a populator (like the TreePopulator) i add it to the list, and return the list, full thing:

    private List<BlockPopulator> populators = new ArrayList<>();
    public void addPopulator(BlockPopulator populator) {
    public List<BlockPopulator> getDefaultPopulators(World world) {
        return populators;
    in my chat method (as a test) i do:

    MyBlockGenerator blockGen = new MyBlockGenerator(); 
    CustomChunkGenerator chunkGen = new CustomChunkGenerator(blockGen);
    TreePopulator treePop = new TreePopulator();
    WorldGenerator worldGen = new WorldGenerator("MyTestingWorld");
    and thats pretty much all of it, any help is appreciated!
  2. Offline

    timtower Moderator Moderator

  3. Offline


    diden't think about that, i will try and report it

    it now ends with

    "12.10 15:22:40 [Server] Server thread/INFO Nerfing mobs spawned from spawners: false"

    and after 30 seconds or so it proceeds with

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Oct 12, 2020
  4. Offline


    What is the bukkit version you are trying to use?
  5. Offline


    1.16.3, wait, i have 1.16.2 i think, let me try update

    EDIT: nvm i have 1.16.3
    Last edited: Oct 12, 2020
  6. Offline


    still no luck, but i have made a step forward, i have figured wich class is causing the problem:

    so i tested my code with just

    WorldGenerator worldGen = new WorldGenerator("MyTestingWorld");

    and surprisingly, it worked!

    however, when adding in the chunk generator

    MyBlockGenerator blockGen = new MyBlockGenerator();
    CustomChunkGenerator gen = new CustomChunkGenerator(blockGen);
    WorldGenerator worldGen = new WorldGenerator("MyTestingWorld");

    it caused the error, i will try to make it work without the block generation, and ill see how it goes

    ok, i tried and it dosent generate the world, at all. i will try again to getting this to work

    after looking more, i found out that on line 69 (nice) c.createWorld() throws an error, but it dosent say wich, ill find it

    ok now, what was i thinking, bukkit's page said

    currentHeight = (int) (generator.noise(chunkX*16+X, chunkZ*16+Z, 0.5D, 0.5D)*15D+50D);

    i did

    currentHeight = (int) ((generator.noise(chunkX * 16 + X, chunkZ * 16 + Z, 0.5D, 0.5D, true) + 1) * 15D+ 50D);

    ill try it again

    EDIT: it now works!
    Last edited: Oct 13, 2020

Share This Page