2024-12-14 16:42:52 +01:00
|
|
|
--- a/net/minecraft/util/datafix/DataFixers.java
|
|
|
|
+++ b/net/minecraft/util/datafix/DataFixers.java
|
2025-05-28 13:23:32 +02:00
|
|
|
@@ -515,6 +_,24 @@
|
2024-12-14 16:42:52 +01:00
|
|
|
Schema schema44 = builder.addSchema(1456, SAME_NAMESPACED);
|
|
|
|
builder.addFixer(new EntityItemFrameDirectionFix(schema44, false));
|
2025-04-12 17:26:44 +02:00
|
|
|
Schema schema45 = builder.addSchema(1458, V1458::new);
|
2024-12-14 16:42:52 +01:00
|
|
|
+ // CraftBukkit start
|
2025-05-25 09:21:37 +02:00
|
|
|
+ // 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) {
|
2024-12-14 16:42:52 +01:00
|
|
|
+ @Override
|
2025-05-25 09:21:37 +02:00
|
|
|
+ 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));
|
2024-12-14 16:42:52 +01:00
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ // CraftBukkit end
|
2025-04-12 17:26:44 +02:00
|
|
|
builder.addFixer(new EntityCustomNameToComponentFix(schema45));
|
|
|
|
builder.addFixer(new ItemCustomNameToComponentFix(schema45));
|
|
|
|
builder.addFixer(new BlockEntityCustomNameToComponentFix(schema45));
|