TransWikia.com

How to detect if somebody is holding something while activating a noteblock

Arqade Asked by Astro Leaf on December 7, 2020

So I’m building a map with right-click detection via a noteblock and I have this command:

/execute if block 21 107 38 minecraft:note_block[note=1] if entity @p[x=21,y=107,z=38,nbt={SelectedItem:[{id:"minecraft:arrow"}]}] run say hi

But when I’m holding an arrow while making the noteblock go to note one, the command doesn’t fire.

One Answer

It'll only run if the players chordanates are the same as the note block chords. /execute if block 21 107 38 minecraft:note_block[note=1] if entity @p[x=21,y=107,z=38,nbt={SelectedItem:[{id:"minecraft:arrow"}]}] run say hi If it dosn't matter where they are, remove x y and z from inside the square brackets, if it does matter change the chordanates. You also have to add distance=..1

Answered by CrazyOlHoboJoe on December 7, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP