diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/ComponentRewriter1_21.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/ComponentRewriter1_21.java index 409895843..031bf9529 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/ComponentRewriter1_21.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/ComponentRewriter1_21.java @@ -19,10 +19,12 @@ package com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter; import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.nbt.tag.ListTag; +import com.viaversion.nbt.tag.StringTag; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPacket1_20_5; import com.viaversion.viaversion.protocols.v1_20_5to1_21.Protocol1_20_5To1_21; import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.util.Key; import com.viaversion.viaversion.util.SerializerVersion; import com.viaversion.viaversion.util.TagUtil; import com.viaversion.viaversion.util.UUIDUtil; @@ -34,8 +36,24 @@ public final class ComponentRewriter1_21 extends ComponentRewriter { @@ -62,6 +64,26 @@ public final class ComponentRewriter1_21_2 extends ComponentRewriter(Collections.singletonList(nameTag))); + + componentsTag.put("minecraft:custom_name", new StringTag(output.toString(output.toComponent(name)))); + } } public static void convertAttributes(final CompoundTag componentsTag, final FullMappings mappings) { diff --git a/common/src/main/java/com/viaversion/viaversion/util/TagUtil.java b/common/src/main/java/com/viaversion/viaversion/util/TagUtil.java index ac34fe676..bd20aa0f5 100644 --- a/common/src/main/java/com/viaversion/viaversion/util/TagUtil.java +++ b/common/src/main/java/com/viaversion/viaversion/util/TagUtil.java @@ -60,6 +60,10 @@ public final class TagUtil { return tag.remove(Key.namespaced(key)) != null || tag.remove(Key.stripMinecraftNamespace(key)) != null; } + public static boolean containsNamespaced(final CompoundTag tag, final String key) { + return tag.contains(Key.namespaced(key)) || tag.contains(Key.stripMinecraftNamespace(key)); + } + public static @Nullable CompoundTag getNamespacedCompoundTag(final CompoundTag tag, final String key) { final CompoundTag compoundTag = tag.getCompoundTag(Key.namespaced(key)); return compoundTag != null ? compoundTag : tag.getCompoundTag(Key.stripMinecraftNamespace(key));