Datapack to use and photo of issue. Had to made it separate due to Jira not working properly with initial submission
To reproduce, put game into hard mode and creative. Set time to night. Then run this command:
/scoreboard objectives add dummyobjective dummy
Now run this command so we can see when a leader zombie is found
/scoreboard objectives setdisplay sidebar dummyobjective
Fly around the world at night, running this command every so often:
/execute as @e[type=zombie] store success score @s dummyobjective run attribute @s spawn_reinforcements modifier value get minecraft:leader_zombie_bonus
When a UUID shows with a score of 1, you found a leader zombie. Run the data get command on the UUID shown and you can see the zombie has the health boost attribute but their health value is still at 20 instead of the new max health.
/data get entity <UUID>
Can confirm the issue still persists in 1.21.10
After digging through the code some more, the issue appears to be that the
CARVERSandFEATURESChunkStatus are set toFINAL_HEIGHTMAPSEnumSet to specify what heightmaps to update for that status and also to persists to disk for the chunk if the chunk unloads and read from the chunk later.However, if the chunk never unloads, the chunk will continue to hold the
WORLD_SURFACE_WGheightmap in memory (frozen in state because it does not get updated anymore due to not being in the chunkstatus’s EnumSet anymore) and the entirety of Feature and Structure generation is relying on this undefined behavior.Thus when the
CARVERSChunkStatus chunk unloads, theWORLD_SURFACE_WGheightmap is erased from memory and not saved to disk either. Thus when chunk is loaded again, the heightmap snapping code defaults to the non-worldgen heightmaps that were previously being updated to include features and structure block placements. Which then causes Village roads on tree.Yep, worldgen is literally built upon non-persistent worldgen heightmap memory state. A possible fix could be to make
SerializableChunkDatasave and read all available heightmaps present if the chunk is not aFULLChunkStatus chunk.