-
Bug
-
Resolution: Fixed
-
Minecraft 1.10.2, Minecraft 1.12.2
-
None
-
Unconfirmed
-
(Unassigned)
Note: I've never seen it happen in vanilla. This is purely based on code analysis and tests with artificial delay in one place in the code. I found it while working on a mod.
When Minecraft saves a chunk there is a brief moment when that chunk is neighter loaded, nor queued for saving, nor saved, and access to region file isn't blocked. Since saving chunks is done in separate thread, it is possible that loading a chunk that is currently being saved but not yet being written to disk loads old version or if there is none - regenerates that chunk.
The problem in code, based on decompiled source from MCP 9.30 and forge 1.10.2 decompiled source, taking patches into account (ignoring forge specific code):
AnvilChunkLoader.loadChunk checks if the chunk is in chunksToRemove map to see if it's unloaded and waiting to be saved.
AnvilChunkLoaded.writeNextIO removes the chunk it writes to disk before it starts writing the data. The time between removing that chunk from chunksToRemove and starting writing it to disk is usually very short so it's almost impossible to see it in practice.
To test if it really is possible I added artificial delay in that place and added code to check if the same chunk is generated more than once. After a few minutes of flying around I got a few chunks that generated more than once.