Interface CombatTracker


@NullMarked @Experimental @NonExtendable public interface CombatTracker
Represents entity's combat tracker
  • Method Details

    • getEntity

      LivingEntity getEntity()
      Gets the entity behind this combat tracker.
      Returns:
      the entity behind this combat tracker
    • getCombatEntries

      List<CombatEntry> getCombatEntries()
      Gets the list of recorded combat entries.

      The returned list is a copy, so any modifications to its contents won't affect this entity's combat history.

      Returns:
      the list of combat entries
      See Also:
    • setCombatEntries

      void setCombatEntries(List<CombatEntry> combatEntries)
      Sets the entity's combat history.

      Note that overriding the entity's combat history won't affect the entity's current or new combat state. Reset the current combat state and register new combat entries instead if you want the new history to affect the combat state.

      Parameters:
      combatEntries - combat entries
      See Also:
    • computeMostSignificantFall

      @Nullable CombatEntry computeMostSignificantFall()
      Calculates the most significant fall damage entry.
      Returns:
      the most significant fall damage entry
    • isInCombat

      boolean isInCombat()
      Checks whether the entity is in combat, i.e. has taken damage from an entity since the combat tracking has begun.
      Returns:
      whether the entity is in combat
    • isTakingDamage

      boolean isTakingDamage()
      Checks whether the entity has started recording damage, i.e. its combat tracking is active.
      Returns:
      whether the entity has started recording damage
    • getCombatDuration

      int getCombatDuration()
      Gets the last or current combat duration.
      Returns:
      the combat duration
      See Also:
    • addCombatEntry

      void addCombatEntry(CombatEntry combatEntry)
      Adds a new entry the pool of combat entries, updating the entity's combat state.
      Parameters:
      combatEntry - combat entry
    • getDeathMessage

      Component getDeathMessage()
      Constructs a death message based on the current combat history.
      Returns:
      a death message
    • resetCombatState

      void resetCombatState()
      Resets entity's combat state, clearing combat history.
    • calculateFallLocationType

      @Nullable FallLocationType calculateFallLocationType()
      Calculates the fall location type from the current entity's location.
      Returns:
      the fall location type