Currently world generation is done on the main thread, this is fine at startup however during runtime this causes other players to be unable to do anything until the world is generated and loaded.
I was wondering if there is a way to, or any plans to, allow a world to be generated and loaded asynchronously? The reason I ask is because we may be converting our server plugins to use Sponge, the one thing holding us back is not being able to generate/load worlds asynchronously, as worlds are constantly being generated on the server and we do not want other players to be affected by the generation.
I tried simply using an async task with the Scheduler to create the world however it failed as expected due to an NPE somewhere.
That looks promising, although that requires a dependency on Forge, and also means we need to handle instantiating worlds as well, it could all get quite messy. However it may work well as a temporary solution to the problem.
Having a dependency on Forge is bad, because it means that the plugin (or part of the plugin) will not work on SpongeVanilla.
Also what I mean by instantiating worlds is, basically I want to generate a brand new world asynchronously, we can’t use the WorldBuilder in Sponge as in doing so it start the world generation process… synchronously.
Unless I maybe set “keepSpawnInMemory” to false and make it generate asynchronously from there… hmm. Will report back.
This is my attempt at async world loading, but the Runnable seems to just be executed straight away and the player falls into the void until the world is generated. Even if I add a 20 second delay til the player is moved to the new world it isn’t loaded.