mojira.dev
MC-236889

/execute store does not work with a conditional array selection

Usually, when using execute store with data get, when the selected path is an array, the length of the array is returned back and stored at the desired location.
This does not seem to work with a conditional array selection.

Steps to Reproduce

  1. /data merge storage bug:test {testArray: [{bool: true}, {bool: false}, {bool: true}]}
    /data merge storage bug:test {testArray: [{bool: true}, {bool: false}, {bool: true}]}
  2. /scoreboard objectives add test dummy
    /scoreboard objectives add test dummy
  3. /scoreboard objectives setdisplay sidebar test
    /scoreboard objectives setdisplay sidebar test
  4. /execute store result score $test test run data get storage bug:test testArray[{bool: true}]
    /execute store result score $test test run data get storage bug:test testArray[{bool: true}]

    -> ❌ Stores 0

  5. /execute store result score $test test run data get storage bug:test testArray
    /execute store result score $test test run data get storage bug:test testArray

    -> ✔ Stores 3

Observed result

The value "0" is stored and the error message "This argument accepts a single NBT value" is printed (which is simply wrong, as the 2nd case with a non-conditional access shows)

Expected result

The value "2" is stored to the score

Attachments

Comments 2

The counterpart to the conditional path testArray[{bool: true}] is not testArray but rather testArray[]; while the first selects the list itself (and returns its length), the second, like the conditional path, selects values inside the list.

Therefore I believe this is intended. Instead, you can achieve this in this way:

/execute store result score $test test if data storage bug:test testArray[{bool: true}]
/execute store result score $test test if data storage bug:test testArray[{bool: true}]

I can confirm this.

NeunEinser

(Unassigned)

Confirmed

Platform

Normal

Commands

command, execute, store

1.17.1, 1.21

Retrieved