From f1fc1b30be4023a6c4ba510aaf5da7c5e61d5fb0 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Fri, 26 Apr 2024 17:41:36 -0700 Subject: [PATCH] readd old UUID format patch --- ...1039-Support-old-UUID-format-for-NBT.patch | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) rename removed-patches-1-20-5/0405-Support-old-UUID-format-for-NBT.patch => patches/server/1039-Support-old-UUID-format-for-NBT.patch (58%) diff --git a/removed-patches-1-20-5/0405-Support-old-UUID-format-for-NBT.patch b/patches/server/1039-Support-old-UUID-format-for-NBT.patch similarity index 58% rename from removed-patches-1-20-5/0405-Support-old-UUID-format-for-NBT.patch rename to patches/server/1039-Support-old-UUID-format-for-NBT.patch index c75408835..890622566 100644 --- a/removed-patches-1-20-5/0405-Support-old-UUID-format-for-NBT.patch +++ b/patches/server/1039-Support-old-UUID-format-for-NBT.patch @@ -8,7 +8,7 @@ We have stored UUID in plenty of places that did not get DFU'd So just look for old format and load it if it exists. diff --git a/src/main/java/net/minecraft/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java -index c7945686a4ee50d7a9d5f1173aa90e456f68b410..23916b011ed0645ab284fb080c9555921290d875 100644 +index df246d69591e1a5822a0109c99b0f67996da71fa..4e005b7b062e3231f564d284887ea1c2783a4e7d 100644 --- a/src/main/java/net/minecraft/nbt/CompoundTag.java +++ b/src/main/java/net/minecraft/nbt/CompoundTag.java @@ -232,6 +232,12 @@ public class CompoundTag implements Tag { @@ -45,22 +45,19 @@ index c7945686a4ee50d7a9d5f1173aa90e456f68b410..23916b011ed0645ab284fb080c955592 Tag tag = this.get(key); return tag != null && tag.getType() == IntArrayTag.TYPE && ((IntArrayTag)tag).getAsIntArray().length == 4; } -diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java -index 3e395d575fab2348cd30a88511a194aba2d8e4ba..f3b11b08358fdd93464cd19b05047e10727a5799 100644 ---- a/src/main/java/net/minecraft/nbt/NbtUtils.java -+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java -@@ -65,6 +65,14 @@ public final class NbtUtils { - @Nullable - public static GameProfile readGameProfile(CompoundTag nbt) { - UUID uUID = nbt.hasUUID("Id") ? nbt.getUUID("Id") : Util.NIL_UUID; -+ // Paper start - Support old UUID format -+ if (nbt.contains("Id", Tag.TAG_STRING)) { -+ try { -+ uUID = UUID.fromString(nbt.getString("Id")); -+ } catch (IllegalArgumentException ignored){ -+ } -+ } -+ // Paper end - Support old UUID format - String string = nbt.getString("Name"); - - try { +diff --git a/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java b/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java +index d8ed3404e8c3c61b2daff110ef32ef890a77a461..f5f1156744b45da3873f68c080ba2a55cbaec506 100644 +--- a/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java ++++ b/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java +@@ -20,9 +20,10 @@ public record ResolvableProfile(Optional name, Optional id, Proper + instance -> instance.group( + ExtraCodecs.PLAYER_NAME.optionalFieldOf("name").forGetter(ResolvableProfile::name), + UUIDUtil.CODEC.optionalFieldOf("id").forGetter(ResolvableProfile::id), ++ UUIDUtil.STRING_CODEC.lenientOptionalFieldOf("Id").forGetter($ -> Optional.empty()), // Paper + ExtraCodecs.PROPERTY_MAP.optionalFieldOf("properties", new PropertyMap()).forGetter(ResolvableProfile::properties) + ) +- .apply(instance, ResolvableProfile::new) ++ .apply(instance, (s, uuid, uuid2, propertyMap) -> new ResolvableProfile(s, uuid2.or(() -> uuid), propertyMap)) // Paper + ); + public static final Codec CODEC = Codec.withAlternative( + FULL_CODEC, ExtraCodecs.PLAYER_NAME, name -> new ResolvableProfile(Optional.of(name), Optional.empty(), new PropertyMap())