If at the time of saving the world, the most recent /forceload add
or /forceload remove
command failed (e.g. if a data pack does /forceload add
to the same chunk periodically), then no changes to any force-loaded chunks are saved at all.
The cause of this is that a single chunk's dirty state overwrites the dirty state of all force-loaded chunks (which are stored in chunks.dat
).
Reproduction steps:
/forceload add 0 0
/forceload add 0 0
Save and restart the world.
/forceload query
→ ❌
No force loaded chunks were found in minecraft:overworld
Code analysis (by @unknown):
In net.minecraft.server.level.ServerLevel#setChunkForced
, the dirty state of chunks.dat
is set to the result of addition/removal of a forced chunk. If the server saves/stops with the dirty state false
, forced chunks will not be saved in chunks.dat
properly.
Linked issues
is duplicated by 1
relates to 2
Comments 9
@atenfyr
The cause of this issue is that a dirty state of a single chunk overwrites the dirty state of all the forceload chunks (chunks.dat
). A workaround is never to make /forceload add|remove
fail by using the following functions whenever adding/removing a forceload chunk. Then the chunks.dat
is kept dirty and is always saved.
forceload/add.mcfunction
execute store success storage mc-143952: marked byte 1.0 run forceload query ~ ~ execute if data storage mc-143952: {marked: false} run forceload add ~ ~
forceload/remove.mcfunction
execute store success storage mc-143952: marked byte 1.0 run forceload query ~ ~ execute if data storage mc-143952: {marked: true} run forceload remove ~ ~
@intsuc
Making sure that the latest /forceload command on a server doesn't fail did the trick. Thanks!
Can confirm for 22w19a, this is also the same as MC-170764
Confirmed in 1.19.3. Can someone please update the title and description to actually be accurate? The issue has nothing to do with whether it was one chunk or multiple chunks. The title should communicate that data/chunks.dat
doesn't save if the most recent /forceload
command failed at the time of saving. The first comment's reproduction steps and code analysis would be good to replace the current inaccurate description.
If appropriate, I wouldn't mind taking ownership of this issue and making these edits myself.
Confirmed for 1.15.2 and 20w08a.
Precise reproduction steps:
Save and restart the world.
→ ❌
No force loaded chunks were found in minecraft:overworld
Code analysis:
In
net.minecraft.server.level.ServerLevel#setChunkForced
, the dirty state ofchunks.dat
is set to the result of addition/removal of a forced chunk. If the server stops with the dirty statefalse
, forced chunks will not be saved inchunks.dat
properly.