mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 20:52:12 -07:00
Fix ancient player custom name converter
Who knows for how long it's been broken, but it only came up now given DataConverter isn't applied Fixes #12565 Supersedes #12568
This commit is contained in:
@@ -122,7 +122,6 @@ public net.minecraft.tags.TagEntry id
|
||||
public net.minecraft.tags.TagEntry required
|
||||
public net.minecraft.tags.TagEntry tag
|
||||
public net.minecraft.util.datafix.fixes.BlockStateData register(ILcom/mojang/serialization/Dynamic;[Lcom/mojang/serialization/Dynamic;)V
|
||||
public net.minecraft.util.datafix.fixes.EntityCustomNameToComponentFix fixCustomName(Lcom/mojang/serialization/DynamicOps;Ljava/lang/String;Ljava/lang/String;)Lcom/mojang/serialization/Dynamic;
|
||||
public net.minecraft.util.datafix.fixes.ItemIdFix ITEM_NAMES
|
||||
public net.minecraft.util.datafix.fixes.ItemSpawnEggFix ID_TO_ENTITY
|
||||
public net.minecraft.world.BossEvent color
|
||||
|
@@ -1,16 +1,22 @@
|
||||
--- a/net/minecraft/util/datafix/DataFixers.java
|
||||
+++ b/net/minecraft/util/datafix/DataFixers.java
|
||||
@@ -541,6 +_,18 @@
|
||||
@@ -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
|
||||
+ builder.addFixer(new com.mojang.datafixers.DataFix(schema45, false) {
|
||||
+ // 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 com.mojang.datafixers.TypeRewriteRule makeRule() {
|
||||
+ return this.fixTypeEverywhereTyped("Player CustomName", this.getInputSchema().getType(References.PLAYER), (typed) -> {
|
||||
+ return typed.update(DSL.remainderFinder(), (dynamic) -> {
|
||||
+ return EntityCustomNameToComponentFix.fixCustomName(dynamic.getOps(), dynamic.get("CustomName").asString(""), "minecraft:player");
|
||||
+ 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));
|
||||
+ });
|
||||
+ });
|
||||
+ }
|
||||
|
Reference in New Issue
Block a user