If this is possible, the player who fired the arrow, either by UUID or by username, should be stored somewhere for each arrow.
First I checked the wiki for an arrow entity's NBT data. But as you said, while ThrownEnderpearl
, ThrownExpBottle
, ThrownPotion
, and Snowball
all have an ownerName
field, Arrow
does seem to have anything indicating it would store the player who fired it.
I fired an arrow and checked its NBT in game, as I've noticed the wiki occasionally misses out data tags:
But again there was nothing that stored my player ID. (Note that UUIDMost and UUIDLeast are both for identifying the entity itself, not who fired it)
I wanted to see if the data of who shot an arrow persists through the world closing and opening. To do this, I:
- Created a world
- Shot an arrow straight up
- Closed the world
- Opened the world
- Quickly opened the world to LAN
- Logged in with an account that was on survival, positioned directly below the arrow
When the arrow hit the survival player, not only was no ping sound played for hitting a player, but the message in chat simply showed that the player was shot by "Arrow", rather than me:
(Note that both players were logged on, the one that shot the arrow and the one that got hit by it)
Because of this, I believe that the player who fired an arrow is not actually stored anywhere in an arrow's data.
Thus the answer to "Is there any way to summon arrows that are shot by a player or mob?" unfortunately seems to simply be no.
I suspect death messages and ping sounds are done temporarily in code, rather than stored anywhere that can be manipulated with commands. They are lost when the world reloads, and are not stored anywhere in the individual arrow's data.
Since Arrows don't contain the data of what bow shot it from, we must mark the arrow as its being shot.
Setup:
/scoreboard objectives add Shot stat.useItem.minecraft.bow
/scoreboard objectives add Holding dummy
/scoreboard objectives add LightingArrow dummy
/scoreboard objectives add InGround dummy
Clock(20tps)
/scoreboard players set @a Holding 0
/scoreboard players set @a Holding 1 {SelectedItem:{tag:{display:{Name:"Lightning Bow"}}}}
/execute @a[score_Shot_min=1,score_Holding_min=1] ~ ~ ~ scoreboard players set @e[type=Arrow,r=2] LightingArrow 1
/scoreboard players set @e[type=Arrow] InGround 1 {inGround:1b}
/execute @e[type=Arrow,score_LightingArrow_min=1,score_InGround_min=1] ~ ~ ~ summon LightningBolt ~ ~ ~
/kill @e[type=Arrow,score_LightingArrow_min=1,score_InGround_min=1]
/scoreboard players set @a Shot 0
Best Answer
You can't make arrows fly straight with just commands. You seem good enough with commands, so Ill just give you the basic idea.
change any arrow you shoot with the entity of a fireball. You could potentially make it an arrow riding an invisible fireball, but Im not sure how well that would work. You can't easily tell an arrow to face what direction you shot it in, so the arrow would simply be flying forward on an invisible fireball facing downward. There is no way to make an arrow fly straight without using that method. It doesn't look good, and I would recommend trying some different idea altogether than making arrows fly straight. You could tell the arrow to face a certain direction by sensing your direction and facing in that direction. There are endless possible directions you could be facing, and to even get a rough approximation of the arrow facing the direction you want you would need hundreds, if not thousands of command blocks.