From 2baa8e4c39de2cf7d9b0afca8c3c919c5b4fde01 Mon Sep 17 00:00:00 2001 From: laforetbrut Date: Thu, 26 Mar 2026 20:25:50 +0100 Subject: [PATCH] Fix RS2: use createCodec() not getMapCodec() - wrong return type ROOT CAUSE: getMapCodec(Runnable) returns MapCodec (not Codec). createCodec(Runnable) returns Codec>. Reflection on getMapCodec silently failed because the returned MapCodec.decode() has a different signature than Codec.decode(). Both save fallback and restore codec paths now use createCodec(). RS2 uses ErrorHandlingMapCodec with UUIDUtil.STRING_CODEC for keys, so the encoded format IS a CompoundTag with UUID strings as keys. Vyrriox --- .../java/vip/fubuki/playersync/sync/addons/ModsSupport.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 34236d9..5f996c4 100644 --- a/src/main/java/vip/fubuki/playersync/sync/addons/ModsSupport.java +++ b/src/main/java/vip/fubuki/playersync/sync/addons/ModsSupport.java @@ -483,7 +483,7 @@ public class ModsSupport { try { // Get the map codec from StorageRepositoryImpl java.lang.reflect.Method getMapCodecMethod = - repo.getClass().getDeclaredMethod("getMapCodec", Runnable.class); + repo.getClass().getDeclaredMethod("createCodec", Runnable.class); getMapCodecMethod.setAccessible(true); @SuppressWarnings("rawtypes") com.mojang.serialization.Codec codec = (com.mojang.serialization.Codec) @@ -558,7 +558,7 @@ public class ModsSupport { com.mojang.serialization.Codec mapCodec; try { java.lang.reflect.Method getMapCodecMethod = - repo.getClass().getDeclaredMethod("getMapCodec", Runnable.class); + repo.getClass().getDeclaredMethod("createCodec", Runnable.class); getMapCodecMethod.setAccessible(true); mapCodec = (com.mojang.serialization.Codec) getMapCodecMethod.invoke(null, (Runnable) () -> {}); } catch (Exception e) {