Solved Error setting biome

Discussion in 'Spigot Plugin Development' started by eccentric, Feb 11, 2020.

Thread Status:
Not open for further replies.
  1. I'm having intermittent errors when trying to set the biome in a world.
    Steps to reproduce:
    1. Fresh server, startup first time allow plugins to generate worlds
    2. Stop server
    3. Start server again
    4. Immediately login, use plugin to load a custom schematic and place the blocks into a world that the player is NOT in. The methods calls World#setBiome(x,z);
    5. NPE setting biome (see below).
    6. Try again after pulling hair out, and it works without issues.
    Code (Text):
    Caused by: java.lang.NullPointerException
        at org.bukkit.craftbukkit.v1_15_R1.CraftWorld.setBiome( ~[spigot.jar:git-Spigot-c574e08-708be69]
        at ~[?:?]
    I have checked that the world is not null and the chunk is not null. I preload the chunk(s) before placing blocks.
    I also realise that World#setBiome(x, z) is now deprecated, but the method just calls the non-deprecated one anyway so shouldn't be an issue.
    The line that throws the error is (in
    Code (Text):

    chunk.getBiomeIndex().setBiome(x >> 2, y >> 2, z >> 2, bb);
    Which to me would mean that the biome index is null.
    I can catch the NPE when it occurs and the schematic will continue to be placed, but that's a pretty inelegant solution.
    Does anybody know what the heart of the problem might be?
  2. #2 eccentric, Feb 11, 2020
    Last edited: Feb 11, 2020
  3. Fixed by changing the chunk generator code to actually set the biome properly when the chunk is generated...
Thread Status:
Not open for further replies.