-
Notifications
You must be signed in to change notification settings - Fork 9
Dummy class error
When you get the following error:
java.lang.UnsupportedOperationException: This is a dummy class, used because a custom world generator was registered. However, either the author forgot to use WorldGenerator.setBaseTerrainGenerator(...), or a plugin is directly calling this method.
See https://github.com/rutgerkok/WorldGeneratorApi/wiki/Dummy-class-error for more information.
Or, for older versions of WorldGeneratorApi:
java.lang.UnsupportedOperationException: This is a dummy class, used because a custom world generator was registered, but no base chunk generator has been set. Please use WorldGenerator.setBaseChunkGenerator(...).
Read on.
Minecraft world generation is a delicate process, with multiple steps allowing various levels of access to neighboring chunks. The Bukkit API stems from simpler times, so glueing it to the current world generator is challenging. Instead, WorldGeneratorApi is designed such that the Bukkit ChunkGenerator API is not used.
To satisfy the Bukkit API, WorldGeneratorAPI provides you with a dummy ChunkGenerator. This ChunkGenerator isn't used by Minecraft as long as you set your own base terrain generator, either using WorldGenerator.setBaseTerrainGenerator
(tutorial), or using a noise generator (tutorial).
Other plugins can also directly call this method. Like for vanilla worlds (which use the same complex multi-step world generator), this will result in an error. To generate fresh terrain, a plugin will need to perform the following workaround:
- Create a second world with the same seed and environment. This is done using the
WorldBuilder
class of Bukkit. - Set the dummy ChunkGenerator from the world as the chunk generator of this world.
- WorldGeneratorApi will make sure that the base terrain generator (and all other changes to the world generator) are carried over to this new world.
- Then grab blocks or entire chunks from this second new world, and copy those over to the original world. (Or do whatever you want with it.)
WorldEdit already uses this workaround for implementing //regen
, so you're in good company. You can even use Paper's async chunk loading API for this secondary world, so that the server isn't blocked while you are generating terrain.
Note that you can never generate a single chunk; if you ask the world generator to generate a single chunk then a large amount of chunks around it are also partially generated. Generating the first chunk is therefore very slow, as actually hundreds of chunks are generated at once. However, once you then force a chunk next to it to generate, as it just needs to apply some final touches to an already partially generated chunk, so this is quite fast.