1

I was trying to detect whether a player had a certain amount of items in their inventory.

I can detect if a player has an item in their inventory like this: /execute as @a[nbt={Inventory:[{id:"minecraft:command_block"}]}] run say hi

But I thought there was a Count tag too. So I tried this, but it doesn't work: /execute as @a[nbt={Inventory:[{id:"minecraft:command_block",Count:5}]}] run say hi

Is there a way to make this work?

0

NBT setting can often be done without types, namespaces or similar, but testing has to be exact:

/execute as @a[nbt={Inventory:[{id:"minecraft:command_block",Count:5b}]}]

Also, keep in mind that this will not match a player with e.g. one stack of 2 and one stack with 3 command blocks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.