Testing for the presence of a compound or the emptiness of a list works as expected; testing for numerical or string values always fails. As such:
Always fail
@a[nbt={OnGround:1b}]
@e[type=item,nbt={Item:{id:"minecraft:stone"}}]
Work as expected
@a[nbt={}]
@a[nbt={Inventory:[]}]
@e[type=item,nbt={Item:{}}]
@e[nbt={ArmorItems:[{}]}]
Linked issues
is duplicated by 3
relates to 1
Comments 9
Further explaining what Alexander said
Examples:
/execute at @s[nbt={Dimension:0}] run say test | Will not work
/execute at @s[nbt={}] run say test | Will work
/execute at @e[type=skeleton,name="Tester",nbt={HurtTime:4s}] run say test | Will not work
So anything testing NBT will not work and there will not be an error message.
Hmm... I cannot reproduce this issue by dropping a birch log item and using
@e[type=item,nbt={Item:{id:"minecraft:birch_log",Count:1b}}]
it works just fine.
this also works fine for me:
execute if block -1451 4 843 dispenser{Items:[{id:"minecraft:dispenser"}]} run say yes
@unknown, check the other examples. I'd like to know if this is actually not an issue anymore- or if it may be still an issue.
Try
/execute as @s[nbt={SelectedItem:{id:"minecraft:diamond"}}] run say Success!
while holding a diamond.
Thanks!
This is apparent for all NBT put in a selector, except for an empty NBT string: