From b694a0515bdd67dc7bdca0c7b31d06d3e94b8e75 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Sun, 21 Jan 2024 13:21:36 +0800 Subject: [PATCH] Implement axiom:modify logic for tag merging --- .../packet/ManipulateEntityPacketListener.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/moulberry/axiom/packet/ManipulateEntityPacketListener.java b/src/main/java/com/moulberry/axiom/packet/ManipulateEntityPacketListener.java index 89da687..dc31da8 100644 --- a/src/main/java/com/moulberry/axiom/packet/ManipulateEntityPacketListener.java +++ b/src/main/java/com/moulberry/axiom/packet/ManipulateEntityPacketListener.java @@ -176,6 +176,11 @@ public class ManipulateEntityPacketListener implements PluginMessageListener { } private static CompoundTag merge(CompoundTag left, CompoundTag right) { + if (right.contains("axiom:modify")) { + right.remove("axiom:modify"); + return right; + } + for (String key : right.getAllKeys()) { Tag tag = right.get(key); if (tag instanceof CompoundTag compound) { @@ -183,9 +188,14 @@ public class ManipulateEntityPacketListener implements PluginMessageListener { left.remove(key); } else if (left.contains(key, Tag.TAG_COMPOUND)) { CompoundTag child = left.getCompound(key); - merge(child, compound); + child = merge(child, compound); + left.put(key, child); } else { - left.put(key, tag.copy()); + CompoundTag copied = compound.copy(); + if (copied.contains("axiom:modify")) { + copied.remove("axiom:modify"); + } + left.put(key, copied); } } else { left.put(key, tag.copy());