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:
parent
12645a1d3d
commit
e9620eb07e
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user