Fix RS2: use createCodec() not getMapCodec() - wrong return type
ROOT CAUSE: getMapCodec(Runnable) returns MapCodec (not Codec). createCodec(Runnable) returns Codec<Map<UUID, SerializableStorage>>. 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
This commit is contained in:
parent
bce7a73cb8
commit
2baa8e4c39
|
|
@ -483,7 +483,7 @@ public class ModsSupport {
|
||||||
try {
|
try {
|
||||||
// Get the map codec from StorageRepositoryImpl
|
// Get the map codec from StorageRepositoryImpl
|
||||||
java.lang.reflect.Method getMapCodecMethod =
|
java.lang.reflect.Method getMapCodecMethod =
|
||||||
repo.getClass().getDeclaredMethod("getMapCodec", Runnable.class);
|
repo.getClass().getDeclaredMethod("createCodec", Runnable.class);
|
||||||
getMapCodecMethod.setAccessible(true);
|
getMapCodecMethod.setAccessible(true);
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
com.mojang.serialization.Codec codec = (com.mojang.serialization.Codec)
|
com.mojang.serialization.Codec codec = (com.mojang.serialization.Codec)
|
||||||
|
|
@ -558,7 +558,7 @@ public class ModsSupport {
|
||||||
com.mojang.serialization.Codec mapCodec;
|
com.mojang.serialization.Codec mapCodec;
|
||||||
try {
|
try {
|
||||||
java.lang.reflect.Method getMapCodecMethod =
|
java.lang.reflect.Method getMapCodecMethod =
|
||||||
repo.getClass().getDeclaredMethod("getMapCodec", Runnable.class);
|
repo.getClass().getDeclaredMethod("createCodec", Runnable.class);
|
||||||
getMapCodecMethod.setAccessible(true);
|
getMapCodecMethod.setAccessible(true);
|
||||||
mapCodec = (com.mojang.serialization.Codec) getMapCodecMethod.invoke(null, (Runnable) () -> {});
|
mapCodec = (com.mojang.serialization.Codec) getMapCodecMethod.invoke(null, (Runnable) () -> {});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user