0

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.

  • I would guess that the answer is simple: Get shot by a blaze and execute /data get entity @e[type=small_fireball,limit=1]. If there's anything including an ID, then it's possible, otherwise not. – Fabian Röling Aug 2 at 5:49
  • @FabianRöling What do you mean by getting shot by a blaze and using /data get? How does that help me set the originator of the damage? – Nik3141 Aug 2 at 5:55
  • If there is some "ShooterID" or whatever, that's the blaze. That's how it's done for snowballs etc. If there's nothing like that, it's probably hardcoded in some some other way. – Fabian Röling Aug 2 at 6:38
2

small_fireballs 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 and OwnerUUIDLeast (not documented in the wiki yet)
  • dragon_fireball: none
  • egg: owner.M and owner.L
  • ender_pearl: owner.M and owner.L
  • experience_bottle: owner.M and owner.L
  • fireball: none
  • llama_spit: Owner.OwnerUUIDMost and Owner.OwnerUUIDLeast
  • potion: owner.M and owner.L
  • shulker_bullet: Owner.M and Owner.L (Yes, capitalised. They also store the shooter coordinates.)
  • small_fireball: none
  • snowball: owner.M and owner.L
  • spectral_arrow: Owner.OwnerUUIDMost and Owner.OwnerUUIDLeast
  • trident: Owner.OwnerUUIDMost and Owner.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)

  • 1
    It's pretty strange that all three versions of fireballs don't have an 'owner', as well as the wither skull. Maybe it's because in normal survival it's unnecessary as only one entity can produce each type of projectile? Also, is Mojang really bad at being consistent or is there a reason that all of the capitalizations and names are different? – Nik3141 Aug 2 at 17:44
  • The same is true for all the tags that hold the age of an entity. And there the values aren't even consistent, some are the time the entity existed for, some are 0 when the mob grows up and negative before, … – Fabian Röling Aug 2 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.