The bug
When specifying an NBT path you're unable to let a compound be followed by a list after specifying the index.
Examples
(1) /execute if data entity @s SelectedItem{id:"minecraft:stone"}
(2) /execute if data entity @s Inventory[0]{id:"minecraft:stone"}
(1) is allowed and tests whether the SelectedItem
of the player is stone, (2) is not allowed but should test whether the first compound in the Inventory
list has an id
of minecraft:stone
.
Linked issues
is duplicated by 1
Comments 9
Can you post example of that? Stuff like '/data modify block 28 56 158 {} merge from block 30 56 158 {Items:[{}]}' works without problems. But as I said, that's special case and only works on root. Also, you can't '/data modify {} set' or '/data remove ... {}'.
This makes things like checking if a mob has a specific item in its offhand directly impossible. The only workaround I've found so far is copying the NBT somewhere else and then checking there. But that loses the reference to the entity.
It seems from your first comment, @unknown, that you plan to add such a behaviour in the future. Then why is this report closed as WAI?
A syntax like
HandItems[1]{id:"minecraft:stone"}
shouldn't collide with anything.
{...} part is not parsed on it's own, it only exist as part of key{...}. Allowing this syntax would complicate
/data remove
, so it does not seem worth the effort. If we add filtering on index+context, it will probably use different syntax.NOTE: Of course there is exception to this rule: {...} can be used to match root, since there is no other syntax. This does not conflict, since you can't remove root anyway.