2

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)

  • 1
    Oh wow, it still shows that I edited the question, even though I undid it within 5 minutes. That's weird. It's just a habit by now to remove minecraft-redstone from minecraft-commands questions, but this is actually one of the rare cases where it's correctly used together! – Fabian Röling Aug 15 '19 at 10:26
4

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.