rutgerkok / WorldGeneratorApi

Minecraft Spigot plugin that enables other plugins to customize world generation
MIT License
96 stars 9 forks source link

Exceptions when trying to use a custom BiomeGenerator with 1.16.1 #11

Closed MichaelHilus closed 4 years ago

MichaelHilus commented 4 years ago

Describe the bug When trying to set a custom biome generator, exceptions are thrown.

To Reproduce Steps to reproduce the behavior:

  1. Follow steps of the BiomeGenerator tutorial: https://github.com/rutgerkok/WorldGeneratorApi/wiki/Biome-generators
  2. Reference worldgeneratorapi via maven (I had to use version 1.1-SNAPSHOT because 1.0 could not be found)
  3. Use either the @EventHandler method or the getDefaultWorldGenerator() method to call setBiomeGenerator()
  4. When using the @EventHandler method: see exceptions at startup.
  5. When using the getDefaultWorldGenerator() method with multiverse: see exceptions when using /mv create ...

Log files

When trying the @EventHandler approach, this is thrown during server startup for each non-FLAT world:

Could not pass event WorldGeneratorInitEvent to NeoplexxFarmworld v1.16.1-beta.1
java.lang.RuntimeException: Failed to update the biome generator field - old value is still present
    at nl.rutgerkok.worldgeneratorapi.internal.bukkitoverrides.InjectedChunkGenerator.injectWorldChunkManager(InjectedChunkGenerator.java:394) ~[?:?]
    at nl.rutgerkok.worldgeneratorapi.internal.bukkitoverrides.InjectedChunkGenerator.setBiomeGenerator(InjectedChunkGenerator.java:416) ~[?:?]
    at nl.rutgerkok.worldgeneratorapi.internal.WorldGeneratorImpl.setBiomeGenerator(WorldGeneratorImpl.java:235) ~[?:?]
    at com.neoplexx.neoplexxfarmworld.NeoplexxFarmWorldPlugin.onWorldGeneratorInit(NeoplexxFarmWorldPlugin.java:54) ~[?:?]
    at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor24.execute(Unknown Source) ~[?:?]
    at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:69) ~[patched_1.16.1.jar:git-Paper-68]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:607) ~[patched_1.16.1.jar:git-Paper-68]
    at nl.rutgerkok.worldgeneratorapi.internal.WorldGeneratorApiImpl.lambda$0(WorldGeneratorApiImpl.java:76) ~[?:?]
    at java.util.HashMap.computeIfAbsent(Unknown Source) ~[?:1.8.0_191]
    at nl.rutgerkok.worldgeneratorapi.internal.WorldGeneratorApiImpl.getForWorld(WorldGeneratorApiImpl.java:53) ~[?:?]
    at nl.rutgerkok.worldgeneratorapi.internal.WorldGeneratorApiImpl.onWorldInit(WorldGeneratorApiImpl.java:101) ~[?:?]
    at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor15.execute(Unknown Source) ~[?:?]
    at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:69) ~[patched_1.16.1.jar:git-Paper-68]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:607) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.craftbukkit.v1_16_R1.CraftServer.createWorld(CraftServer.java:1159) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.Bukkit.createWorld(Bukkit.java:570) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.WorldCreator.createWorld(WorldCreator.java:320) ~[patched_1.16.1.jar:git-Paper-68]
    at com.onarandombox.MultiverseCore.utils.WorldManager.doLoad(WorldManager.java:467) ~[?:?]
    at com.onarandombox.MultiverseCore.utils.WorldManager.doLoad(WorldManager.java:448) ~[?:?]
    at com.onarandombox.MultiverseCore.utils.WorldManager.doLoad(WorldManager.java:423) ~[?:?]
    at com.onarandombox.MultiverseCore.utils.WorldManager.loadWorlds(WorldManager.java:728) ~[?:?]
    at com.onarandombox.MultiverseCore.MultiverseCore.onEnable(MultiverseCore.java:310) ~[?:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:380) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:483) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.craftbukkit.v1_16_R1.CraftServer.enablePlugin(CraftServer.java:500) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.craftbukkit.v1_16_R1.CraftServer.enablePlugins(CraftServer.java:414) ~[patched_1.16.1.jar:git-Paper-68]
    at net.minecraft.server.v1_16_R1.MinecraftServer.loadWorld(MinecraftServer.java:471) ~[patched_1.16.1.jar:git-Paper-68]
    at net.minecraft.server.v1_16_R1.DedicatedServer.init(DedicatedServer.java:241) ~[patched_1.16.1.jar:git-Paper-68]
    at net.minecraft.server.v1_16_R1.MinecraftServer.v(MinecraftServer.java:940) ~[patched_1.16.1.jar:git-Paper-68]
    at net.minecraft.server.v1_16_R1.MinecraftServer.lambda$a$0(MinecraftServer.java:177) ~[patched_1.16.1.jar:git-Paper-68]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_191]

and this is thrown for each FLAT world:

Could not pass event WorldGeneratorInitEvent to NeoplexxFarmworld v1.16.1-beta.1
java.lang.IllegalArgumentException: Can not set final net.minecraft.server.v1_16_R1.GeneratorSettingBase field net.minecraft.server.v1_16_R1.ChunkGeneratorAbstract.h to net.minecraft.server.v1_16_R1.ChunkProviderFlat
    at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source) ~[?:1.8.0_191]
    at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source) ~[?:1.8.0_191]
    at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(Unknown Source) ~[?:1.8.0_191]
    at sun.reflect.UnsafeQualifiedObjectFieldAccessorImpl.get(Unknown Source) ~[?:1.8.0_191]
    at java.lang.reflect.Field.get(Unknown Source) ~[?:1.8.0_191]
    at nl.rutgerkok.worldgeneratorapi.internal.WorldGeneratorImpl.extractSettings(WorldGeneratorImpl.java:47) ~[?:?]
    at nl.rutgerkok.worldgeneratorapi.internal.WorldGeneratorImpl.replaceChunkGenerator(WorldGeneratorImpl.java:172) ~[?:?]
    at nl.rutgerkok.worldgeneratorapi.internal.WorldGeneratorImpl.setBiomeGenerator(WorldGeneratorImpl.java:233) ~[?:?]
    at com.neoplexx.neoplexxfarmworld.NeoplexxFarmWorldPlugin.onWorldGeneratorInit(NeoplexxFarmWorldPlugin.java:54) ~[?:?]
    at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor24.execute(Unknown Source) ~[?:?]
    at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:69) ~[patched_1.16.1.jar:git-Paper-68]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:607) ~[patched_1.16.1.jar:git-Paper-68]
    at nl.rutgerkok.worldgeneratorapi.internal.WorldGeneratorApiImpl.lambda$0(WorldGeneratorApiImpl.java:76) ~[?:?]
    at java.util.HashMap.computeIfAbsent(Unknown Source) ~[?:1.8.0_191]
    at nl.rutgerkok.worldgeneratorapi.internal.WorldGeneratorApiImpl.getForWorld(WorldGeneratorApiImpl.java:53) ~[?:?]
    at nl.rutgerkok.worldgeneratorapi.internal.WorldGeneratorApiImpl.onWorldInit(WorldGeneratorApiImpl.java:101) ~[?:?]
    at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor15.execute(Unknown Source) ~[?:?]
    at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:69) ~[patched_1.16.1.jar:git-Paper-68]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:607) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.craftbukkit.v1_16_R1.CraftServer.createWorld(CraftServer.java:1159) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.Bukkit.createWorld(Bukkit.java:570) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.WorldCreator.createWorld(WorldCreator.java:320) ~[patched_1.16.1.jar:git-Paper-68]
    at com.onarandombox.MultiverseCore.utils.WorldManager.doLoad(WorldManager.java:467) ~[?:?]
    at com.onarandombox.MultiverseCore.utils.WorldManager.doLoad(WorldManager.java:448) ~[?:?]
    at com.onarandombox.MultiverseCore.utils.WorldManager.doLoad(WorldManager.java:423) ~[?:?]
    at com.onarandombox.MultiverseCore.utils.WorldManager.loadWorlds(WorldManager.java:728) ~[?:?]
    at com.onarandombox.MultiverseCore.MultiverseCore.onEnable(MultiverseCore.java:310) ~[?:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:380) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:483) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.craftbukkit.v1_16_R1.CraftServer.enablePlugin(CraftServer.java:500) ~[patched_1.16.1.jar:git-Paper-68]
    at org.bukkit.craftbukkit.v1_16_R1.CraftServer.enablePlugins(CraftServer.java:414) ~[patched_1.16.1.jar:git-Paper-68]
    at net.minecraft.server.v1_16_R1.MinecraftServer.loadWorld(MinecraftServer.java:471) ~[patched_1.16.1.jar:git-Paper-68]
    at net.minecraft.server.v1_16_R1.DedicatedServer.init(DedicatedServer.java:241) ~[patched_1.16.1.jar:git-Paper-68]
    at net.minecraft.server.v1_16_R1.MinecraftServer.v(MinecraftServer.java:940) ~[patched_1.16.1.jar:git-Paper-68]
    at net.minecraft.server.v1_16_R1.MinecraftServer.lambda$a$0(MinecraftServer.java:177) ~[patched_1.16.1.jar:git-Paper-68]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_191]

Both exception types are thrown then using the getDefaultWorldGenerator() approach and calling /mv create when creating FLAT or non-FLAT worlds.

MichaelHilus commented 4 years ago

Looks like ChunkGenerator in 1.16.1 now has two fields b and c both of type WorldChunkManager. May this break things here?

rutgerkok commented 4 years ago

Nice to see that people are using this API. And the benefit of writing a plugin for other plugin developers, is that you get great bug reports. 😄

Should now be fixed.