Minecraft Java Edition – How to Implement Remote Detonation Arrows

minecraft-commandsminecraft-java-edition

I'm making more weapons in minecraft with command blocks. I have been able to create a bow with explosive arrows, but I can't figure out how to make it so you can shoot multiple arrows and then click with an item in your hand to explode the arrows. This would be like launching c4 with a bow. Thanks.

Best Answer

What you have to do is put a tag on the arrow when the player is shooting it. If you have any special requirements and tags for the player, put it in the []. If there aren't any tags, get rid of the [].

/execute @a[] ~ ~ ~ scoreboard players tag @e[type=Arrow,r=2] add c4

If you put this on a repeating command block, all arrows shot from the player will have the c4 tag.

Then, create a scoreboard called "click".

/scoreboard objectives add click stat.useItem.minecraft.carrot_on_a_stick

Just for working with it, set it to the sidebar.

/scoreboard objectives setdisplay sidebar click

Now whenever you right click with a carrot on a stick, you will add 1 to your click score.

Make a chain coming from that first repeating command block with the following commands in this order.

/execute @a[score_click_min=1,*other selectors here*] ~ ~ ~ execute @e[type=Arrow,tag=c4] ~ ~ ~ summon *whatever you need* *wherever* *NBT tags*
/execute @a[score_click_min=1,*other selectors here*] ~ ~ ~ kill @e[type=Arrow,tag=c4]
/scoreboard players set @a[] click 0

If you want to add more effects to the arrows before they are killed, use

/execute @a[score_click_min=1,*other selectors here*] ~ ~ ~ execute @e[type=Arrow,tag=c4] ~ ~ ~ *command*

and add it after the first command block. I hope this helped!