From f0911d4f2d71b26e1c113ae083ad8ddf9b991e58 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 --- .../Support-old-UUID-format-for-NBT.patch | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) rename removed-patches-1-20-5/0405-Support-old-UUID-format-for-NBT.patch => patches/server/Support-old-UUID-format-for-NBT.patch (64%) diff --git a/removed-patches-1-20-5/0405-Support-old-UUID-format-for-NBT.patch b/patches/server/Support-old-UUID-format-for-NBT.patch similarity index 64% rename from removed-patches-1-20-5/0405-Support-old-UUID-format-for-NBT.patch rename to patches/server/Support-old-UUID-format-for-NBT.patch index 7f7bec5337..658ffcc5c5 100644 --- a/removed-patches-1-20-5/0405-Support-old-UUID-format-for-NBT.patch +++ b/patches/server/Support-old-UUID-format-for-NBT.patch @@ -45,22 +45,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 +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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/nbt/NbtUtils.java -+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java -@@ -0,0 +0,0 @@ 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 { +--- a/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java ++++ b/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java +@@ -0,0 +0,0 @@ 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())