How to detect if an arrow hits certain coordinates in 1.14

I am making a puzzle map where the player has to hit some Redstone lamps with an arrow and then they will light up. How do I detect if an arrow has hit some certain coordinates instead of a certain type of block (which Is all that I have found so far)


In your case, you can simply use wooden buttons or pressure plates. They get activated by arrows hitting them and they can be attached directly to lamps.

If you want to use commands to detect if an arrow has hit at certain coordinates, then you can use one of these commands:

/execute positioned 12 34 56 if entity @e[type=arrow,distance=..1,nbt={inGround:1b}] run <command>
/execute if entity @e[type=arrow,x=12,y=34,z=56,dx=0,dy=0,dz=0,nbt={inGround:1b}] run <command>

If it should work for any lamp, then I recommend this command:

/execute at @e[type=arrow,nbt={inBlockState:{Properties:{lit:"false"},Name:"minecraft:redstone_lamp"}}] run fill ~-0.05 ~-0.05 ~-0.05 ~0.05 ~0.05 ~0.05 minecraft:redstone_lamp[lit=true] replace minecraft:redstone_lamp[lit=false]

It will replace any non-lit redstone lamps in a small volume around any arrow that is inside a non-lit redstone lamp with a lit redstone lamp. You can change the target selector to also check if it's inside a certain block, or area.

When the arrow disappears, then the lamp will stay lit until it has a blockupdate. If you hit a non-lit redstone lamp near the edge, then other redstone lamps near the arrow may also get lit.