mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-02 13:12:03 -07:00
Who knows for how long it's been broken, but it only came up now given DataConverter isn't applied Fixes #12565 Supersedes #12568
28 lines
1.6 KiB
Diff
28 lines
1.6 KiB
Diff
--- a/net/minecraft/util/datafix/DataFixers.java
|
|
+++ b/net/minecraft/util/datafix/DataFixers.java
|
|
@@ -541,6 +_,24 @@
|
|
Schema schema44 = builder.addSchema(1456, SAME_NAMESPACED);
|
|
builder.addFixer(new EntityItemFrameDirectionFix(schema44, false));
|
|
Schema schema45 = builder.addSchema(1458, V1458::new);
|
|
+ // CraftBukkit start
|
|
+ // API allows setting player custom names, so we need to convert them.
|
|
+ // This does *not* handle upgrades in any other version, but generally those shouldn't need conversion.
|
|
+ builder.addFixer(new DataFix(schema45, false) {
|
|
+ @Override
|
|
+ protected TypeRewriteRule makeRule() {
|
|
+ return this.fixTypeEverywhereTyped("Player CustomName", this.getInputSchema().getType(References.PLAYER), typed -> {
|
|
+ return typed.update(DSL.remainderFinder(), dynamic -> {
|
|
+ final String customName = dynamic.get("CustomName").asString("");
|
|
+ if (customName.isEmpty()) {
|
|
+ return dynamic.remove("CustomName");
|
|
+ }
|
|
+ return dynamic.set("CustomName", LegacyComponentDataFixUtils.createPlainTextComponent(dynamic.getOps(), customName));
|
|
+ });
|
|
+ });
|
|
+ }
|
|
+ });
|
|
+ // CraftBukkit end
|
|
builder.addFixer(new EntityCustomNameToComponentFix(schema45));
|
|
builder.addFixer(new ItemCustomNameToComponentFix(schema45));
|
|
builder.addFixer(new BlockEntityCustomNameToComponentFix(schema45));
|