-
Bug
-
Resolution: Invalid
-
None
-
1.18.1, 1.18.2 Pre-release 2
-
Plausible
-
(Unassigned)
The bug
Unlike the other NBT operations that may stop traversing the NBT path early when the current parent NBTs are empty, /data remove always traverses the NBT path to the end.
Code analysis
net/minecraft/commands/arguments/NbtPathArgument.java
public static class NbtPath { ... public int remove(Tag target) { var parents = Collections.singletonList(target); for(var i = 0; i < nodes.length - 1; ++i) { parents = nodes[i].get(parents); // If `parents` is empty, we could return 0 here. } return apply(parents, nodes[nodes.length - 1]::removeTag); } ... }