Minecraft – way to target the arrow from an OP bow via command block

minecraft-commandsminecraft-java-edition

I am trying to make an effect trail for a specific weapon in MC, a bow with power 120. I want to use a command block to target any arrow with the damage it should be doing (63) and summon a trail of splash potions.

I also want to kill any arrow entities that have inGround=True

Is there any way to do this or do I have to come up with something else?

Attempt:

/execute @e[type=Arrow,damage=63,inGround=0] ~ ~ ~ summon ThrownPotion ~ ~ ~ {Potion:{id:potion,Damage:8197}}
/kill @e[type=Arrow,inGround=True]

Each unfortunately just affects all arrows. Is this even possible?

Best Answer

Target selectors do not support direct NBT data input. You must assign a label to the target using /scoreboard first, and then target the entity based on its label.

Prerequisites:

Objective to hold the value.

/scoreboard objectives add SpecialArrow dummy

Clock commands:

The following must be run in numerical order on a clock.

  1. Assign a score based on the arrow's NBT data. Note that you must properly declare tag-types; in this case, "damage" has a tag-type of double, so you must include a decimal, while "inGround" has a tag-type of byte, so its value is appended with a "b". The command assigns a score of 1 if the arrow has a particular damage as well as not being in the ground.

    /scoreboard players set @e[type=Arrow] SpecialArrow 1 {damage:63.0,inGround:0b}
    
  2. Perform the commands you'd like, targeting arrows with a SpecialArrow score of exactly 1.

    /execute @e[type=Arrow,score_SpecialArrow_min=1,score_SpecialArrow=1] ~ ~ ~ summon ThrownPotion ~ ~ ~ {Potion:{id:potion,Damage:8197}}
    
  3. Afterwards, the score is set to 2 if that particular arrow is now in the ground.

    /scoreboard players set @e[type=Arrow] SpecialArrow 2 {damage:63.0,inGround:1b}
    
  4. And finally, the /kill command, targeting based on score.

    /kill @e[type=Arrow,score_SpecialArrow_min=2]