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}}
Best Answer
The correct command would be:
You only include a
tag
tag when testing for items, not when giving or clearing them.