mojira.dev
MC-129232

Command NBT comparisons that include strings or numbers always fail

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

Comments 9

This is apparent for all NBT put in a selector, except for an empty NBT string:

/execute if entity @s[nbt={}] run say worked!

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.

This also affects container blocks such as chest and hopper

@unknown as in execute if block with nbt data?

FVbico I have a commands using execute and testing for blocks with nbt and it doesn't work

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!

That works for me just fine.
Resolving as fixed.

Jerry Cheng

(Unassigned)

Confirmed

nbt

Minecraft 18w19a

Minecraft 18w19b

Retrieved