Issue Description
When a custom dimension is added to an existing world, removed, and then readded, the NBT data used to register the dimension is lost.
This is important because the game does not keep track of all dimensions, which means when a world is upgraded to a newer version of Minecraft, there can be unseen complications when loading the custom dimension in the upgraded world.
Reproduction Steps:
Create a new Minecraft workspace using version 1.16.5.
Load the workspace in Debug Mode so breakpoints can be added later.
Create a new world in 1.16.5 vanilla
Save and Quit to Title Screen
Add a datapack containing a custom dimension to the existing world we previously created.
Load the world, and select the "Create a Backup and Load Option" when the WorldOption screen is displayed.
Verify the custom dimension was added via the
/execute incommand suggestions.
Teleport to the custom dimension to load it.
This can be done via the
/execute incommand.
Place blocks in the dimension to allow it to have different chunk data.
Save and Quit to Title Screen
Remove the datapack from the world.
Add breakpoint to Line 908 of SaveFormat.java. The line of code is
Dynamic<T> dynamic1 = fixer.update(TypeReferences.WORLD_GEN_SETTINGS, dynamic, version, SharedConstants.getVersion().getWorldVersion());
The above names are MCP names, let me know if you need Mojang Mapping names
Load the world that now has the datapack removed.
See that the nbt data in the CompountNBT tagMap inside the
Dynamic<T>at your break point contains the custom dimension alongside the other vanilla dimensions.
Continue to step through until the WorldOptions screen is displayed.
Click the “Create Backup and Load” option at the World Options Screen.
See that you will be teleported to the Overworld now that the datapack dimension was removed.
Save and Quit to World
Readd datapack dimension into world save
Reopen World Save
See that only vanilla dimensions (In this case the Overworld) are present in the CompountNBT tagMap of Dynamic<T> dynamic1 (Line 98 of SaveFormat.java)
The reason only the Overworld is present is because of another outstanding vanilla bug, https://bugs.mojang.com/browse/MC-197860 .
We can now see that NBT DATA FOR CUSTOM DIMENSIONS ARE “MISSING” after the custom dimension is readded.
Tools Used:
Custom Dimension Test Datapack: https://www.mediafire.com/file/k3xn8qhf4biwsu6/custom_dimension_test_datapack.zip/file
Third Party build tool (Minecraft Forge)
Additional Information:
Full writeup of reproduction test procedure and tools used can be seen in my document:
https://drive.google.com/file/d/1WkcHXeM5BW_Li5gH_h-p_3wF3kX-OQ4s/view?usp=sharing
If this is still an issue, please provide steps to reproduce that do not involve modding the game