Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Add combat tracker API #11853

wants to merge 3 commits into from

Conversation

SoSeDiK
Copy link
Contributor

@SoSeDiK SoSeDiK commented Dec 28, 2024

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.

@SoSeDiK SoSeDiK requested a review from a team as a code owner December 28, 2024 21:46
Comment on lines 31 to 32
* Mutating the list is safe and won't have
* an effect on this entity's combat history.
Copy link
Member

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

Copy link
Contributor Author

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);
Copy link
Member

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?

Copy link
Contributor Author

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.

- Rename FallLocation to FallLocationType
- Change CombatTracker#getCombatEntries javadoc
@SoSeDiK SoSeDiK requested a review from kennytv December 29, 2024 11:26
@NoahvdAa NoahvdAa added the type: feature Request for a new Feature. label Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature Request for a new Feature.
Projects
Status: Awaiting review
Development

Successfully merging this pull request may close these issues.

3 participants