Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Add lastDamageSource to living entities

Open Fusezion opened this issue 6 months ago • 3 comments

Is your feature request related to a problem?

Supporting lastDamageSource is from my perspective a better implementation to lastDamageCause and provides the same and more information to the users. Especially in cases where a custom damage type might be defined.

Describe the solution you'd like.

I would like a method added onto LivingEntity preferably like #getLastDamageSource matching it along with getLastDamage and getLastDamageCause

Describe alternatives you've considered.

I haven't considered any alternatives to this implementation

Other

While I'm aware that getLastDamageCause returns EntityDamageEvent I find this behavior of it in poor taste, I would rather use a method provided by minecraft than one that I assume is custom made by the server.

Fusezion avatar May 17 '25 22:05 Fusezion

Have you looked at the CombatTracker API? the last CombatEntry provides you with a bunch of information, including the damage source.

A convenience method for that on LivingEntity itself might be neat though.

Malfrador avatar May 17 '25 22:05 Malfrador

I have looked over it but since the only reliable way I could see of getting last being through the list of all entries, I wasn't sure if they stored in the order of being added enabling CombatTracker#getCombatEntries().getLast()

Fusezion avatar May 17 '25 22:05 Fusezion

I have looked over it but since the only reliable way I could see of getting last being through the list of all entries, I wasn't sure if they stored in the order of being added enabling CombatTracker#getCombatEntries().getLast()

you can try but i remember is added in order.

Doc94 avatar May 22 '25 13:05 Doc94