0

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.

1
  • 1
    Just a word of advice, you don't need to check for all of that complex item data, and doing so may not be fully reliable because of text component order. Instead, you can add custom NBT to your item, like /give @p diamond{radiant_gem:1b, display:{...}}. Then you can just do nbt={HandItems:[{tag:{radiant_gem:1b}}]} and it will find your item. Much easier to maintain and reason about.
    – tryashtar
    Jun 20, 2021 at 0:23

1 Answer 1

0

After a bit of thinking and fiddling, I found the problem. There was no error with my command, rather the command block type that I was running it through. If I run the command to check for an entity named radiant_gem with the item in its hand, it works. However, the command to check that never gets run since using a conditional command block requires the last command block (in this case the repeat command block for tp'ing the armor stand) to have executed successfully. Since the item gets taken away for a tick when right clicking it onto the stand, the command to check for the stand doesn't get to run.

Hope this makes a little sense and helps someone out!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .