2

A unique quirk about the /clear command is that it can clear items from the player's cursor, i.e. the one that is picked up and moving from slot to slot. Using this and conditional command blocks, I can detect when someone clicks on an item slot to pick it up. This is useful when I want to prevent a user from removing items from the chest.

A method that I used to detect this is shown here.

The problem is, my method doesn't work if the chest's contents are constantly changing. So I had this idea, to give each item a custom NBT tag like LockedInChest:1b and use my earlier method to detect if items with this tag were removed.

Now I've run into a roadblock. It was all smooth sailing until I realized that you can't specify NBT in the /clear command without specifying an item. For example, I can match "stone with my NBT tag", or "stone with any NBT tag", but I can't mention "any item with my NBT tag".

How can I specify NBT only, and have it work for any item?

Past trials (all failures)

What if I could just remove the item name and keep the NBT?

/clear @s minecraft:stone{NBT}

/clear @s {NBT}

Can I just specify the namespace? minecraft:

/clear @s minecraft:stone{NBT}

/clear @s minecraft:{NBT}

and

/clear @s minecraft{NBT}

Is there a keyword for any item?

/clear @s minecraft:stone{NBT}

/clear @s minecraft:any{NBT}

and

/clear @s minecraft:all{NBT}

Your Answer

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

Browse other questions tagged or ask your own question.