Support old UUID format for NBT

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.
This commit is contained in:
Aikar
2020-06-29 03:26:17 -04:00
parent 4c8c367eee
commit 3844905fa8
2 changed files with 39 additions and 4 deletions

View File

@@ -1,6 +1,18 @@
--- a/net/minecraft/world/item/component/ResolvableProfile.java
+++ b/net/minecraft/world/item/component/ResolvableProfile.java
@@ -49,7 +49,7 @@
@@ -20,9 +20,10 @@
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())
@@ -49,7 +50,7 @@
if (this.isResolved()) {
return CompletableFuture.completedFuture(this);
} else {