So I'm trying to make a quest system using written books and clickEvent's
The idea is if the player declines the quest, the book is removed from their inventory and returned to the quest collection area.
The clickEvent works perfectly, but I can't seem to clear the book from the players inventory
Here is the give command for the written book
/give @p written_book 1 0 {title:"Quest: Exterminator",author:"Edgar",pages:["{text:\"\",extra:[{text:'Sorry to bother you, my attic is absolutely infested with '},{text:'Mice',color:dark_red,bold:true},{text:'! If you could take care of them, I would be extremely grateful!',color:black},{text:' (This is the Quest description)',color:dark_gray,italic:true,underline:true}]}","{text:\"\",extra:[{text:'Quest: Kill all the ',color:dark_purple,italic:true},{text:'Mice',color:dark_red,bold:true,italic:true},{text:' in the attic.',color:dark_purple,italic:true},{text:' (This is the Quest Objective) ',color:dark_gray,italic:true},{text:'Reward: ',color:dark_purple,italic:true},{text:'10 Gold, ',color:gold,italic:true},{text:'10 xp',color:dark_green,italic:true},{text:'(These are the quest rewards) ',color:dark_gray,italic:true},{text:'Accept Quest',color:green,underlined:true,clickEvent:{action:run_command,value:\"/setblock -91 70 231 redstone_block\"}},{text:' (Click to choose) ',color:dark_gray,italic:true},{text:'Ignore Quest',color:red,underlined:true,clickEvent:{action:run_command,value:\"/setblock -89 70 229 redstone_block\"}}]}"]}
Here is the clear command
/clear @p written_book 0 1 {tag:{title:"Quest: Exterminator",author:"Edgar",pages:["{text:\"\",extra:[{text:'Sorry to bother you, my attic is absolutely infested with '},{text:'Mice',color:dark_red,bold:true},{text:'! If you could take care of them, I would be extremely grateful!',color:black},{text:' (This is the Quest description)',color:dark_gray,italic:true,underline:true}]}","{text:\"\",extra:[{text:'Quest: Kill all the ',color:dark_purple,italic:true},{text:'Mice',color:dark_red,bold:true,italic:true},{text:' in the attic.',color:dark_purple,italic:true},{text:' (This is the Quest Objective) ',color:dark_gray,italic:true},{text:'Reward: ',color:dark_purple,italic:true},{text:'10 Gold, ',color:gold,italic:true},{text:'10 xp',color:dark_green,italic:true},{text:'(These are the quest rewards) ',color:dark_gray,italic:true},{text:'Accept Quest',color:green,underlined:true,clickEvent:{action:run_command,value:\"/setblock -91 70 231 redstone_block\"}},{text:' (Click to choose) ',color:dark_gray,italic:true},{text:'Ignore Quest',color:red,underlined:true,clickEvent:{action:run_command,value:\"/setblock -89 70 229 redstone_block\"}}]}"]}}
I know the command are kind of large, but it is necessary for the map.
Both tag's are identical, so I'm not sure what's wrong
After the JSON is parsed, the data will change in variation, including inserted quotes, replacing some string data, and changing the order of the tags. It is not feasible to detect books based on its page data. Instead, I highly recommend adding custom NBT data that can be detected instead:
The "CUSTOM" compound tag is simply a custom tag (you can name it whatever you want) that holds other data, in this case being a tag named "book" with the value 1 and tag-type 'byte'. You don't necessarily need to use the compound tag, but it's best to have a single tag holding the rest of your custom data. Custom data on items are not removed, so you can clear based on that data:
Thanks for your help, I figured out I can just us the title and author tag, also the clear command doesn't need {tag:{}}
I might use that for other things though
The idea is if the player declines the quest, the book is removed from their inventory and returned to the quest collection area.
The clickEvent works perfectly, but I can't seem to clear the book from the players inventory
Here is the give command for the written book
Here is the clear command
I know the command are kind of large, but it is necessary for the map.
Both tag's are identical, so I'm not sure what's wrong
After the JSON is parsed, the data will change in variation, including inserted quotes, replacing some string data, and changing the order of the tags. It is not feasible to detect books based on its page data. Instead, I highly recommend adding custom NBT data that can be detected instead:
The "CUSTOM" compound tag is simply a custom tag (you can name it whatever you want) that holds other data, in this case being a tag named "book" with the value 1 and tag-type 'byte'. You don't necessarily need to use the compound tag, but it's best to have a single tag holding the rest of your custom data. Custom data on items are not removed, so you can clear based on that data:
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
I might use that for other things though