If a vanilla structure's name is changed in the structure registry or is removed, re-entering an already existing world will spam the log with
Failed to read chunk [x, z]
net.minecraft.util.crash.CrashException: Loading NBT data
Failed to store chunk [x, z]
java.lang.NullPointerException: null
Unknown structure start: <missing structure>
Couldn't load chunk [-246, -125]
java.util.concurrent.CompletionException: net.minecraft.util.crash.CrashException: Loading NBT data
and many other issues also including java.io.DataInputStream and java.io.DataOutputStream
Even worst, the player will be able to move around in the world and place/remove blocks but when they exit and re-enter, the world does not save their progress due to the try/catched crash in the chunk saving.
This is a serious issue with how Minecraft does not double check to make sure a structure exists before saving/reading it from memory and will heavily impact Mojang if they ever decide to remove a structure or rename an existing one. The solution would be to fix the bug by checking if structures exist before writing it to memory and when reading it from memory, check again to make sure it exists before storing it into the chunk. That way this bug does not explode or limit Mojang in the future. Right now, this bug is badly hitting the modding community with adding/removing structures so that's why this bug report exists to help make sure Mojang is aware of this issue so they won't get surprised when it happens to them as well.
A workaround right now is to use a third party app like NBTExplorer, go into the world's region files and enter every chunk's mca file, go into the chunk's level > structures > references and remove the missing structure manually from the chunk. However, this will take forever as there's hundreds if not thousands of chunks created in any decently lived world.
I hope this helps!
Edit: I just attached a world filled with missing structures. Upon entering said world, the game will lag, the logs will be spammed, and chunks will not be saved properly anymore.
This can be recreated in any world to simulate removal of structures by going into the world's region folder, opening several .mca with a program like NBTExplorer, go into the chunk's Level, then into Structures, then add long tags into References and Start with names of structures that doesn't exist such as "sky:castle_village" and save. Then enter the world and that chunk when loaded will cause all the issues stated here. For easiness, use the attached saved world to debug and confirm the bug.
Attachments
Comments 11
This isn't a great fix, but the solution I have made for now is to remove any structure references keyed by "null" in the returned of structure reference map. After that, what I do is then force the chunk to save as soon if a null key was present in order to prevent as much future log spam. I have included this fix into Fabric API. This is in yarn mappings but the general description should apply no matter what flavor you use to understand the Minecraft codebase.
The link:
Using NBTExplorer, use the search function to jump to tags referencing removed structures and delete them. I think that should fix it.
Had this same issue on a very big (12gb) world, so I made a python script to automatically remove the offending structure. Feel free to message me if you have trouble using it. https://github.com/Nyveon/MCStructureCleaner
Hey man I'm having this issue but I'm a complete novice with that stuff. How exactly do I get your script to run?
Cannot reproduce in 23w04a. It just logs "Found reference to unknown structure 'sky:castle_village' in chunk [0, 0], discarding", and does not crash. Is anyone still able to reproduce this issue?
Loaded the world in on 1.20.1. The logspam does still happen, but there doesn't appear to be any chunk saving issues. Closing and reopening the world does not cause any blocks added/destroyed to be lost.
Tested on 1.20.5 pre1 and the chunk saving errors still don't happen, I'm pretty sure the issue has been fixed.
Yep, same problem here. My friend and I just upgraded a modded world from 1.15.2 to 1.16(.1), played a few hours and went to bed. Next morning, we saw that nothing has been saved! So I checked the log files and tried loading without mods, optimized the world and so on. Finally, I came to the realization that it worked perfectly fine in 1.15.2, even without mods, but for the love of God wouldn't in 1.16.
In the end I came to the conclusion that one of the mods had removed the specific structure in its 1.16 release, which makes it impossible to upgrade to the new MC version. The check from 1.15 should be ported to 1.16, why was it even removed?