Skip to content

Commit b694a05

Browse files
committed
Implement axiom:modify logic for tag merging
1 parent 8cd2930 commit b694a05

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/main/java/com/moulberry/axiom/packet/ManipulateEntityPacketListener.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,26 @@ public void onPluginMessageReceived(@NotNull String channel, @NotNull Player pla
176176
}
177177

178178
private static CompoundTag merge(CompoundTag left, CompoundTag right) {
179+
if (right.contains("axiom:modify")) {
180+
right.remove("axiom:modify");
181+
return right;
182+
}
183+
179184
for (String key : right.getAllKeys()) {
180185
Tag tag = right.get(key);
181186
if (tag instanceof CompoundTag compound) {
182187
if (compound.isEmpty()) {
183188
left.remove(key);
184189
} else if (left.contains(key, Tag.TAG_COMPOUND)) {
185190
CompoundTag child = left.getCompound(key);
186-
merge(child, compound);
191+
child = merge(child, compound);
192+
left.put(key, child);
187193
} else {
188-
left.put(key, tag.copy());
194+
CompoundTag copied = compound.copy();
195+
if (copied.contains("axiom:modify")) {
196+
copied.remove("axiom:modify");
197+
}
198+
left.put(key, copied);
189199
}
190200
} else {
191201
left.put(key, tag.copy());

0 commit comments

Comments
 (0)