Fix RS2 restore: wrap entry in UUID key before codec decode

ROOT CAUSE from logs:
  "Invalid UUID capacity: Invalid UUID string: capacity"
  "Invalid UUID resources: Invalid UUID string: resources"

We saved the INNER storage data ({type, capacity, resources}) but the
map codec expects {uuid-string: {type, capacity, resources}}.
The codec tried to parse "capacity", "resources", "type" as UUIDs.

FIX: Wrap the stored NBT back in a UUID-keyed CompoundTag before
decoding: wrapped.put(uuid.toString(), storedNbt)

Also increased sync timeout from 15s to 60s - the server was 34s
behind (691 ticks) causing timeout errors for player sync.

Vyrriox
This commit is contained in:
laforetbrut 2026-03-26 20:53:23 +01:00
parent 12645a1d3d
commit e9620eb07e
2 changed files with 8 additions and 2 deletions

View File

@ -397,7 +397,7 @@ public class VanillaSync {
// server.execute() from draining, preventing latch countdown).
lock.unlock();
if (!applyLatch.await(15, TimeUnit.SECONDS)) {
if (!applyLatch.await(60, TimeUnit.SECONDS)) {
PlayerSync.LOGGER.error("Timeout waiting for main thread sync for player {}", player_uuid);
syncNotCompletedPlayer.remove(player_uuid);
}

View File

@ -574,8 +574,14 @@ public class ModsSupport {
for (UUID uuid : diskUuids) {
restoreStorageContents(uuid, (storedNbt) -> {
try {
// FIX: storedNbt is the INNER data ({type, capacity, resources}).
// The map codec expects {uuid-string: {type, capacity, resources}}.
// Wrap the data back in a UUID-keyed CompoundTag before decoding.
net.minecraft.nbt.CompoundTag wrapped = new net.minecraft.nbt.CompoundTag();
wrapped.put(uuid.toString(), storedNbt);
@SuppressWarnings("unchecked")
com.mojang.serialization.DataResult<?> dataResult = fCodec.decode(ops, storedNbt);
com.mojang.serialization.DataResult<?> dataResult = fCodec.decode(ops, wrapped);
Optional<?> opt = dataResult.result();
if (opt.isPresent()) {
com.mojang.datafixers.util.Pair<?, ?> pair = (com.mojang.datafixers.util.Pair<?, ?>) opt.get();