Why does this '/execute at […] run summon' command not work?
-
I am trying to make all arrows shot by the player have lightning bolts summoned on them while they are not on the ground. Here is the command:
/execute at @e[type=minecraft:arrow,nbt={FiredFrom:{id:player}}] run summon lightning_bolt ~ ~ ~
-
First, I wouldn't use the
FiredFrom
nbt tag. There is an nbt tag calledinGround
that suits your purpose nicely.You can test for all arrows that are not inGround like this:
execute as @e[type=arrow,nbt={inGround:0b}] run say I am not inGround
Second, your command uses
execute at
. This is a problem becauseexecute at
only selects one entity to run the command at. If you have multiple arrows in your world, the selected arrow may not be the one you were expecting.To have all arrows summon lightning at their position, you need to use both
as
andat
:execute as @e[type=arrow,nbt={inGround:0b}] at @s run summon lightning_bolt ~ ~ ~