Interface CombatTracker


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

    • getEntity

      LivingEntity getEntity()
      Gets the entity behind this combat tracker.
      Returns:
      the entity behind this combat tracker
      Since:
      1.21.6
    • 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
      Since:
      1.21.6
      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
      Since:
      1.21.6
      See Also:
    • computeMostSignificantFall

      @Nullable CombatEntry computeMostSignificantFall()
      Calculates the most significant fall damage entry.
      Returns:
      the most significant fall damage entry
      Since:
      1.21.6
    • 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
      Since:
      1.21.6
    • 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
      Since:
      1.21.6
    • getCombatDuration

      int getCombatDuration()
      Gets the last or current combat duration.
      Returns:
      the combat duration
      Since:
      1.21.6
      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
      Since:
      1.21.6
    • getDeathMessage

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

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

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