From 797607b9ad09aecf78464f09b3d0aa65b9038aa4 Mon Sep 17 00:00:00 2001 From: Florian Reuth Date: Mon, 15 Jun 2026 01:31:18 +0200 Subject: [PATCH 1/2] Fix tag updating in 1.21.6->1.21.5 Fixes a regression in https://github.com/ViaVersion/ViaBackwards/commit/be0f50ad699d95359c945cbb178f7fc0300de170 that broke dialogs --- .../Protocol1_21_6To1_21_5.java | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_6to1_21_5/Protocol1_21_6To1_21_5.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_6to1_21_5/Protocol1_21_6To1_21_5.java index 88eb5517..78695fca 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_6to1_21_5/Protocol1_21_6To1_21_5.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_6to1_21_5/Protocol1_21_6To1_21_5.java @@ -93,6 +93,9 @@ public Protocol1_21_6To1_21_5() { protected void registerPackets() { super.registerPackets(); + replaceClientbound(ClientboundPackets1_21_6.UPDATE_TAGS, this::updateTags); + replaceClientbound(ClientboundConfigurationPackets1_21_6.UPDATE_TAGS, this::updateTags); + appendClientbound(ClientboundPackets1_21_6.SOUND, wrapper -> { wrapper.passthrough(Types.VAR_INT); // Source fixSoundSource(wrapper); @@ -238,34 +241,24 @@ private void fixSoundSource(final PacketWrapper wrapper) { } private void updateTags(final PacketWrapper wrapper) { - tagRewriter.handleGeneric(wrapper); - wrapper.resetReader(); - + // Store dialog tags; then call the normal rewriter which will remove them before sending to the client final RegistryAndTags registryAndTags = wrapper.user().get(RegistryAndTags.class); final int length = wrapper.passthrough(Types.VAR_INT); for (int i = 0; i < length; i++) { - final String registryKey = wrapper.read(Types.STRING); + final String registryKey = wrapper.passthrough(Types.STRING); final boolean dialog = "dialog".equals(Key.stripMinecraftNamespace(registryKey)); - if (dialog) { - final int tagsSize = wrapper.read(Types.VAR_INT); - for (int j = 0; j < tagsSize; j++) { - final String key = wrapper.read(Types.STRING); - final int[] ids = wrapper.read(Types.VAR_INT_ARRAY_PRIMITIVE); + final int tagsSize = wrapper.passthrough(Types.VAR_INT); + for (int j = 0; j < tagsSize; j++) { + final String key = wrapper.passthrough(Types.STRING); + final int[] ids = wrapper.passthrough(Types.VAR_INT_ARRAY_PRIMITIVE); + if (dialog) { registryAndTags.storeTags(key, ids); } - } else { - wrapper.write(Types.STRING, registryKey); // Write back - final int tagsSize = wrapper.passthrough(Types.VAR_INT); - for (int j = 0; j < tagsSize; j++) { - wrapper.passthrough(Types.STRING); - wrapper.passthrough(Types.VAR_INT_ARRAY_PRIMITIVE); - } } } - if (registryAndTags.tagsSent()) { - wrapper.set(Types.VAR_INT, 0, length - 1); // Dialog tags have been read, remove from size - } + wrapper.resetReader(); + tagRewriter.handleGeneric(wrapper); } private void clearDialog(final PacketWrapper wrapper) { From bf2eada4dcdb412c8fc2e74d97c6881f1f9551a0 Mon Sep 17 00:00:00 2001 From: Florian Reuth Date: Mon, 15 Jun 2026 01:40:47 +0200 Subject: [PATCH 2/2] Remove unused methods --- .../v1_21_6to1_21_5/storage/RegistryAndTags.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_6to1_21_5/storage/RegistryAndTags.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_6to1_21_5/storage/RegistryAndTags.java index d6bb384c..8b04997a 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_6to1_21_5/storage/RegistryAndTags.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_6to1_21_5/storage/RegistryAndTags.java @@ -44,10 +44,6 @@ public CompoundTag fromRegistry(final String key) { return dialogs.get(Key.stripMinecraftNamespace(key)); } - public boolean tagsSent() { - return dialogTags != null && !dialogTags.isEmpty(); - } - public void storeTags(final String key, final int[] ids) { if (dialogTags == null) { dialogTags = new Object2ObjectArrayMap<>(); @@ -55,12 +51,8 @@ public void storeTags(final String key, final int[] ids) { dialogTags.put(Key.stripMinecraftNamespace(key), ids); } - public int[] fromKey(final String key) { - return dialogTags.get(Key.stripMinecraftNamespace(key)); - } - public CompoundTag[] fromRegistryKey(final String key) { - final int[] ids = fromKey(key); + final int[] ids = dialogTags.get(Key.stripMinecraftNamespace(key)); if (ids == null) { return null; }