I'm making a right-click item ability system with a datapack and I ran into a big problem. The system uses armor stands that teleport to you when you hold an item with an ability. This works fine in both creative and adventure. However, when I right click with the item (thus giving it to the armor stand), it doesn't get detected in adventure, but it does in creative. How do I make sure the event gets detected in adventure too?
My command for this is:
execute as @p if entity @e[name=radiant_gem,nbt={HandItems:[{tag:{display:{Name:'[{"text":"Radiant Gem","italic":false,"color":"aqua"}]',Lore:['[{"text":"A luminous glow emits from this jewel,","italic":false,"color":"white"}]','[{"text":"making it look dazzling in the dim","italic":false,"color":"white"}]','[{"text":"light.","italic":false,"color":"white"},{"text":"","italic":false,"color":"dark_purple"}]','[{"text":"","italic":false,"color":"dark_purple"}]','[{"text":"RC Effect:","italic":false,"color":"yellow"},{"text":" ","color":"white"},{"text":"Graceful Healing","color":"gold","bold":true},{"text":"","color":"dark_purple","bold":false}]','[{"text":"Fully heals you and grants Resistance","italic":false,"color":"gray"}]','[{"text":"I upon use. This consumes the item.","italic":false,"color":"gray"}]']},Enchantments:[{}],HideFlags:29},id:"minecraft:diamond"},{}]}] run function dungeon:item_effects/consumables/radiant_gem
I run the command through a Conditional, Always active Chain command block. The chain command block gets activated by a Repeat - Unconditional - Needs redstone command block that tps the armor stand to the player when they hold the item. As I mentioned, the tp part works fine.
Edit: I found out that no item works with this system in Adventure mode. Does anyone know how to detect right-clicks with this system in Adventure mode?
I found a weird quirk. I have a bunch of armor stands set up so when you right click them with a tripwire hook in your hand, it runs a function. That does work in Adventure mode. The only difference between this and the ability armor stands is that this does not tp to the player.
/give @p diamond{radiant_gem:1b, display:{...}}
. Then you can just donbt={HandItems:[{tag:{radiant_gem:1b}}]}
and it will find your item. Much easier to maintain and reason about.