-
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.