mojira.dev
MC-278759

NBT arrays can't be expanded via set/give wrong error

Overview:
When trying to expand an allocated NBT array, it will give the wrong response.

 

To Reproduce:

/data modify storage nbtbug array set value []
/data modify storage nbtbug array[0] set value "value"
Returns "{color:#ff0000}Nothing changed. The specified properties already have these values{color}"
/data get storage nbtbug array[0]
Returns "{color:#ff0000}Found no elements matching array[0]{color}"

 

Expected either:
The error states something like "{color:#ff0000}Nothing changed. Arrays cannot be expanded{color}"
Or it succeeds and data get storage nbtbug array[0] successfully returns "value"

Comments 2

You have to use append to expand an array, you can't set a value that doesn't exist. The error message being misleading would be a different issue, see MC-255915 and MC-176679 for example

you can't set a value that doesn't exist

This is only true for list/array entries though,and even that's not always the case:

/data modify storage test list set value []
/data modify storage test list[{doesnt_exist:1b}].some_value set value 1b

returns

{list:[{doesnt_exist:1b,some_value:1b}]}

(or at least, it used to, haven't checked in a while).

I suggest reopening and letting mojang take a look.

Immodial

(Unassigned)

Confirmed

Platform

Normal

Commands

1.21.4

Retrieved