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

/data modify on the elements of an empty list adds a tag to the list

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.19.2, 1.19.3, 1.21
    • Community Consensus
    • Commands
    • Normal
    • Platform

      The bug

      The data modify command works inconsistently when attempting to modify the elements in an NBT list using the [] pattern in an NBT path. Specifically, when modifying the elements of a non-empty list (e.g. data modify storage foo:bar MyList[] set value 0), all elements of the list are modified and the length of the list is unchanged. However, if the list is initially empty, one element is added to the list.

      How to reproduce

      • Run the following chat commands:
        /data modify storage foo:bar MyList set value []
        /data modify storage foo:bar AnotherList set value [1, 2, 3]
        /data modify storage foo:bar MyList[] set value 5
        /data modify storage foo:bar AnotherList[] set value 5
        /data get storage foo:bar
        
      • AnotherList has been set to [5, 5, 5]
      • MyList has been set to [5]. It is expected that MyList would rather be unchanged, consistently with what happens on non-empty lists.

      This also effects other data modify subcommands. data modify foo:bar MyList[] append value 0 creates a list inside MyList containing 0, data modify foo:bar MyList[] merge value {example: 0} creates a compound inside MyList, etc.

            Unassigned Unassigned
            Aeldrion Aeldrion
            Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              CHK: