(Java Minecraft 1.14) How to attribute damage to a particular source?
Solution 1:
small_fireball
s don't seem to store their shooter in NBT for some reason. They even disappear when the server stops. But most other projectiles store their shooter in NBT:
-
arrow
:OwnerUUIDMost
andOwnerUUIDLeast
(not documented in the wiki yet) -
dragon_fireball
: none -
egg
:owner.M
andowner.L
-
ender_pearl
:owner.M
andowner.L
-
experience_bottle
:owner.M
andowner.L
-
fireball
: none -
llama_spit
:Owner.OwnerUUIDMost
andOwner.OwnerUUIDLeast
-
potion
:owner.M
andowner.L
-
shulker_bullet
:Owner.M
andOwner.L
(Yes, capitalised. They also store the shooter coordinates.) -
small_fireball
: none -
snowball
:owner.M
andowner.L
-
spectral_arrow
:Owner.OwnerUUIDMost
andOwner.OwnerUUIDLeast
-
trident
:Owner.OwnerUUIDMost
andOwner.OwnerUUIDLeast
-
wither_skull
: none
When you copy the UUID (parts) of a player to those tags, that makes it count as shot by that player in all contexts, meaning that pigmen will get angry at that player, XP will drop, they will get advancements and so on. It also works similarly in some ways with other entities, for example you can make two skeletons aggressive at each other that way.
There are also similar tags for the owner of a dog, the thrower of an item, etc.
Source: https://minecraft.gamepedia.com/Chunk_format#Projectiles (archive)