Let's say that I have an item which allows a player to summon blaze fireballs (minecraft:small_fireball
) and shoot them where they are looking. Is it possible for me to somehow attribute damage done by these fireballs to the player that shot them?
When a blaze shoots the fireball and kills a player, the chat says 'Nik3141 was killed by blaze', but when I kill someone else with the fireballs, it says 'Username burned to death'. So the game knows that I am not a blaze shooting the projectile. Other than turning off death messages and trying to do my own custom death messages with tellraw
, is it possible for me to make the chat message say 'Username burned whilst trying to escape Nik3141' or something like that automatically?
This is in a datapack, so anything using advancements is an acceptable solution.
Best Answer
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
: noneegg
:owner.M
andowner.L
ender_pearl
:owner.M
andowner.L
experience_bottle
:owner.M
andowner.L
fireball
: nonellama_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
: nonesnowball
:owner.M
andowner.L
spectral_arrow
:Owner.OwnerUUIDMost
andOwner.OwnerUUIDLeast
trident
:Owner.OwnerUUIDMost
andOwner.OwnerUUIDLeast
wither_skull
: noneWhen 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)