-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add combat tracker API #11853
base: main
Are you sure you want to change the base?
Add combat tracker API #11853
Conversation
* Mutating the list is safe and won't have | ||
* an effect on this entity's combat history. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should just be immutable/say it's a copy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the wording to state it's a copy.
Haven't made this immutable because it's returning a copy internally each time, so modifications are safe. Otherwise, users would need to make a copy of a copy.
* @see #resetCombatState() | ||
* @see #addCombatEntry(CombatEntry) | ||
*/ | ||
void setCombatEntries(List<CombatEntry> combatEntries); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the use of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Sneakily" setting prior combat history without overriding/resetting active combat state.
It's a neat shortcut for providing fake pre-made combat history scenarios and producing specific death messages.
paper-api/src/main/java/io/papermc/paper/world/damagesource/FallLocation.java
Outdated
Show resolved
Hide resolved
- Rename FallLocation to FallLocationType - Change CombatTracker#getCombatEntries javadoc
Adds
LivingEntity#getCombatTracker
to get entity's combat tracker that allows getting/setting combat history (list of damage entries during a combat session), recording new combat entries without causing actual damage, getting/resetting current combat state/session and getting a death message based on the present combat history.FallLocation
represents a location from which the entity fell, and is used by vanilla to generate fall death messages.API implementation is basically done, but definitely open to feedback. Javadocs & namings could use some love.