NucleoidMC / NucleoidMC/fantasy
Support for re-creating persistent worlds
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 143
- Forks
- 48
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 2
Description
The problem
Currently, if you want to load a previously created persistent world, you have to use Fantasy::getOrOpenPersistentWorld.
The method obviously requires you to pass a dimension type and chunk generator via a RuntimeWorldConfig.
If you created the world with a custom generator, you will have to memorize it somehow.
That creates an unnecessary overhead for the developer IMO.
Use case
I personally create worlds for minigames in single player.
Often, I change the generator options, such as the dimension type or the chunk generator in the level.dat.
On my minigame server, I copy the level save into the dimensions directory, every time the game starts.
I would like to load the map as dimension using the fantasy library.
Then, I have to re-create the generator options by hand in Java, for each individual map.
In my case, an API would surely be helpful.
Potential solution
I think there should be an API method on the Fantasy class, such as openPersistentWorld(Identifier) in order to open worlds inside the dimensions/ directory of the currently loaded save.
The method needs to somehow re-construct the RuntimeWorldConfig, the world was created with.
For this to work, fantasy would also need to save the config/the generator data to disk on persistent world creation.
Implementation details
My proposal would be to check whether there is a level.dat file in the directory of the dimension that should be loaded.
If it exists, the code from net.minecraft.world.level.storage.LevelStorage#createLevelDataParser can be used to parse it.
This way, users could also put worlds they created in singleplayer / another world into the dimensions folder of the desired save (my use case).
As for writing the level.dat, one could use net.minecraft.world.level.storage.LevelStorage.Session#backupLevelDataFile().
Maybe there are even better ways to save and load the world data, I am not sure...
Sample implementation
I implemented the level.dat parsing and config re-creation as proof of concept in one of my libraries.
If you like the approach, I would be happy to create a pull request providing the feature to fantasy.
Please let me know, if the concept / the implementation is to your liking.
I am still working on the leve.dat creation when creating a persistent world. So it can only be tested with other saves ATM.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Fantasy persistent-world API and compare the proposed behavior with net.minecraft.world.level.storage.LevelStorage#createLevelDataParser and Session#backupLevelDataFile. Review the proof of concept in WorldPersistenceService.java, then determine how dimensions/level.dat should be read and written. Done means a persistent world can be reopened from its saved data without manually recreating its RuntimeWorldConfig, with tests covering imported saves.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100