Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-248769

"/data remove" always traverses the NBT path to the end

XMLWordPrintable

    • Icon: Bug 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);
          }
      
          ...
      }
      

            Unassigned Unassigned
            intsuc intsuc
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: