mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
readd old UUID format patch
This commit is contained in:
parent
a9b6792b11
commit
f0911d4f2d
@ -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<String> name, Optional<UUID> 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<ResolvableProfile> CODEC = Codec.withAlternative(
|
||||
FULL_CODEC, ExtraCodecs.PLAYER_NAME, name -> new ResolvableProfile(Optional.of(name), Optional.empty(), new PropertyMap())
|
Loading…
Reference in New Issue
Block a user