I have no problem giving a player an item with a custom tag, and I have no problem detecting that item with the specific tag, my issue is running the clear command for that specific item AFTER detecting the item in the player's inventory.

Here is the command to give the player the item:

/give @a minecraft:written_book{LostBoy:1b,title:"Quest: Lost Boy",author:"Easy Quest",generation:0,pages:['{"text":"=====LOST BOY=====\\n\\nEdgar\'s son has gone missing! He was last seen heading to the coal mine West of town. \\n\\nObjective: Investigate the coal mine West of the CrestGaurd slums."}']} 1

Here is the command I'm having issues with, the first part is detecting the book (I've confirmed this through testing with "say" outputs), but the "clear" command will not clear the specific book!

execute as @a[nbt={Inventory:[{id:"minecraft:written_book",tag:{LostBoy:1b},Count:1b}]}] run clear @a minecraft:written_book{tag:{LostBoy:1b}}

The correct command would be:

execute as @a[nbt={Inventory:[{id:"minecraft:written_book",tag:{LostBoy:1b},Count:1b}]}] run clear @a minecraft:written_book{LostBoy:1b}

You only include a tag tag when testing for items, not when giving or clearing them.

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.