What I'm trying to do: Make sure players always have a particular guidebook/spellbook (a special command-generated one with clickable links and a special tag).
If they lose their book, it should appear back in their inventory. If they drop their book, it should do that and the book on the ground should disappear.
I have this working on a basic level, except... Any time a player tries to move their book to a different slot, it gives them a new one, which just feels wrong. There is apparently no inventory slot you can detect for the mouse. Even if there were... This can lead to fast infinite generation if, for instance, they open a chest and repeatedly put that book in that chest.
So the thought process here is maybe make it so that if the player has the inventory GUI open, they are excluded from the selection. So they don't get the book until the inventory is closed. It still leaves some gaps, and they could fill chests with these books. But they would have to try to make it glitch out, and I think it would feel right at that point. And in order to do infinite generation, they'd have to repeatedly open and close the chest.
Here are my commands as it stands. (2 command blocks per spellbook)
/give @a[nbt=!{Inventory:[{id:"minecraft:written_book", tag:{spellbook:basic}}]}] written_book{pages:[...yada...],title:"Spellbook",author:"Dartania @ http://minecraft.tools/",display:{Lore:["You need this for lots of stuff! Don't lose it!"]},spellbook:basic}
/kill @e[nbt={Item:{id:"minecraft:written_book", tag:{spellbook:basic}}}]
What I'm looking to do is add to this part...
@a[nbt=!{Inventory:[{...}]
and make it more like @a[nbt=!{Inventory:[{...}]},nbt=!{Client:{InventoryOpen:true}}]
I know Client:{InventoryOpen}
is not the correct thing, but I don't know what is the correct thing.
For reference, I'm building a Singleplayer/Multiplayer puzzle map on Vanilla Minecraft 1.14, with a bedrock/command_block bunker below spawn. I'm using http://minecraft.tools/ to generate stuff (like the spellbook)
/help
? My players tend to forget about those commands, plus I wanted it to feel like a book. More importantly, I haven't figured out how to open a fake GUI, or detect when players type in a particular command. I might use a tellraw menu screen if I could figure out how to determine when the help button has left the screen. I have considered lots of methods. This one is the easiest with the least amount of help needed. I have it mostly working already. Any other method would require like 50 more QA's like this./tellraw
withclickEvent
. About the Creative inventory: I meant your regular player inventory, but while you are in Creative mode./clear
has a surprisingly specific bug with that, so you should just test your/clear
command in Survival and in the best case drop the item and pick it up a few times before that. The bug is really weird.