Fix RS2 disk save: use return value of SavedData.save()

save() returns the serialized data in a NEW CompoundTag - it does NOT
fill the input parameter. We were passing an empty tag and reading it
back, getting nothing. The actual data was in the return value.

Log showed: "RS2 disk UUID xxx exists in repo but NOT found in save()
NBT. Keys at top: []" - empty because we ignored the return value.

Vyrriox
This commit is contained in:
laforetbrut 2026-03-26 19:30:27 +01:00
parent 50c77f7bb8
commit 4e2574a147

View File

@ -456,8 +456,8 @@ public class ModsSupport {
// Use save() to serialize the in-memory state to a CompoundTag (does NOT touch disk)
if (!(repo instanceof net.minecraft.world.level.saveddata.SavedData sd)) return;
net.minecraft.nbt.CompoundTag fullNbt = new net.minecraft.nbt.CompoundTag();
sd.save(fullNbt, sp.getServer().registryAccess());
// FIX: save() RETURNS the data in a new CompoundTag, it does NOT fill the input parameter
net.minecraft.nbt.CompoundTag fullNbt = sd.save(new net.minecraft.nbt.CompoundTag(), sp.getServer().registryAccess());
// Log the top-level structure once for debugging
PlayerSync.LOGGER.debug("RS2 save() NBT keys: {}", fullNbt.getAllKeys());