From e9620eb07ee8a21bbf3c8a278512d56e083622e8 Mon Sep 17 00:00:00 2001 From: laforetbrut Date: Thu, 26 Mar 2026 20:53:23 +0100 Subject: [PATCH] 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 --- src/main/java/vip/fubuki/playersync/sync/VanillaSync.java | 2 +- .../vip/fubuki/playersync/sync/addons/ModsSupport.java | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/vip/fubuki/playersync/sync/VanillaSync.java b/src/main/java/vip/fubuki/playersync/sync/VanillaSync.java index 9c23671..5bc106a 100644 --- a/src/main/java/vip/fubuki/playersync/sync/VanillaSync.java +++ b/src/main/java/vip/fubuki/playersync/sync/VanillaSync.java @@ -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); } diff --git a/src/main/java/vip/fubuki/playersync/sync/addons/ModsSupport.java b/src/main/java/vip/fubuki/playersync/sync/addons/ModsSupport.java index 828cc2e..c6cd59c 100644 --- a/src/main/java/vip/fubuki/playersync/sync/addons/ModsSupport.java +++ b/src/main/java/vip/fubuki/playersync/sync/addons/ModsSupport.java @@ -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();