Files
paper-mc/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch
Bjarne Koll a24f9b204c 1.21.6 dev
Co-authored-by: Bjarne Koll <git@lynxplay.dev>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
Co-authored-by: Noah van der Aa <ndvdaa@gmail.com>
Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
2025-06-17 15:45:25 +02:00

28 lines
1.6 KiB
Diff

--- a/net/minecraft/util/datafix/DataFixers.java
+++ b/net/minecraft/util/datafix/DataFixers.java
@@ -515,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));