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.
Adding Tags
to the item will not be set as the entity's Tags
data. All the item data itself will be lost except for Potion
and CustomPotionEffects
, which are copied to the arrow entity if existent.
Tipped arrows will be necessary, but you can apply custom effects to reduce any issues should it strike a player or mob, such as setting the duration to 0. Currently the Instant Healing effect does not function on tipped arrows, but you may need to switch to something else should it work in the future.
The amplifier would be how you'd differentiate arrows from one another.
Example arrows to provide:
/give @p minecraft:tipped_arrow 64 0 {CustomPotionEffects:[{Id:6b,Duration:0,Amplifier:0b}]}
/give @p minecraft:tipped_arrow 64 0 {CustomPotionEffects:[{Id:6b,Duration:0,Amplifier:1b}]}
Then you'd label those arrows based on the effects it has, with the amplifier making each one unique:
/scoreboard players tag @e[type=Arrow,tag=!tntarrow] add tntarrow {CustomPotionEffects:[{Id:6b,Duration:0,Amplifier:0b}]}
/scoreboard players tag @e[type=Arrow,tag=!custom2] add custom2 {CustomPotionEffects:[{Id:6b,Duration:0,Amplifier:1b}]}
And finally, target based on that label:
/say @e[type=Arrow,tag=tntarrow] is a "tntarrow".
Best Answer
I did a bit of testing, and it appears that the arrow consistently disappears at 580 ticks (29 seconds), which is lower than a normal arrow's despawn time of 2 minutes.
This does not appear to be affected by the difficulty setting, or the source of the arrow (player, skeleton, dispenser).