From 524e053327de42a06a2e9a0f3dd64ed65d7600c8 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Fri, 14 Jun 2024 17:04:22 +0200 Subject: [PATCH] Don't add tags if they're already in there --- .../viaversion/viaversion/rewriter/TagRewriter.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/TagRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/TagRewriter.java index c996184e8..5325f82f0 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/TagRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/TagRewriter.java @@ -175,8 +175,9 @@ public class TagRewriter implements com.viavers } public void handle(PacketWrapper wrapper, @Nullable IdRewriteFunction rewriteFunction, @Nullable List newTags, @Nullable Map tagsToRename, @Nullable Set tagsToRemove) { - int tagsSize = wrapper.read(Types.VAR_INT); + final int tagsSize = wrapper.read(Types.VAR_INT); final List tags = new ArrayList<>(newTags != null ? tagsSize + newTags.size() : tagsSize); + final Set currentTags = new HashSet<>(tagsSize); for (int i = 0; i < tagsSize; i++) { String key = wrapper.read(Types.STRING); @@ -202,6 +203,7 @@ public class TagRewriter implements com.viavers } tags.add(new TagData(key, ids)); + currentTags.add(Key.stripMinecraftNamespace(key)); } if (tagsToRemove != null) { @@ -210,7 +212,11 @@ public class TagRewriter implements com.viavers // Add new tags if present if (newTags != null) { - tags.addAll(newTags); + for (final TagData tag : newTags) { + if (!currentTags.contains(Key.stripMinecraftNamespace(tag.identifier()))) { + tags.add(tag); + } + } } // Write the tags