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