minecraftminecraft-commands

Execute command if player has bow with certain tag


I have these commands and I want it to only explode the arrow if the player has a bow with the "explode" tag.

Here are the commands (courtesy of AntVenom)

"*" Means that all blocks under it have that property

[Repeat,*Unconditional,*Always Active]
/execute at @e[type=Arrow] ~ ~ ~ run /scoreboard players set @e[c=1,r=0,type=Arrow] inGround 1 {inGround:1b}
[*Chain]
/execute at @e[type=Arrow] ~ ~ ~ run /particle lava ~ ~ ~ .5 .5 .5 .5 30 .5

/execute at @e[type=Arrow,score_inGround_min=1] ~ ~ ~ run /summon PrimedTnt ~ ~1 ~ {Fuse:0}

/kill @e[type=Arrow,score_inGround_min=1]

I could use https://mcstacker.net/ but i'm confused on what to put where. Any help? I had to bump this question


Solution

  • Try execute as @a[nbt={SelectedItem:{id=“bow”,tag:{explode:1b}}}] run say hi

    To give yourself the bow do give @s bow {explode:1b}