Skip to content

[API] Expose the killing entity in PlayerDeathEvent #12525

@OfficialTheosis

Description

@OfficialTheosis

Is your feature request related to a problem?

I want to reliably get the entity involved in killing a player upon their death, if there is one. In cases where an entity is directly responsible for the player's death, this can easily be done with PlayerDeathEvent#getDamageSource#getCausingEntity. However, this returns null in cases where the entity is indirectly responsible, such as when a player is "doomed to fall" by an entity. Calling Player#getKiller is not a solution for this, because that only returns a Player.

Proof that Minecraft tracks the killing entity in these indirect cases:

Image

Describe the solution you'd like.

Some kind of PlayerDeathEvent#getKiller method that returns an Entity representing the entity that is directly, or indirectly, responsible for the player's death, as tracked by Minecraft.

Describe alternatives you've considered.

Already described in the "Is your feature request related to a problem?" section.

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    resolution: won't fixIssue will not be resolved or feature not added.
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions