Class CombatEntry

java.lang.Object
me.gamercoder215.mobchip.combat.CombatEntry

public final class CombatEntry extends Object
Represents a Combat Entry stored in the Entity's EntityCombatTracker
  • Constructor Details

    • CombatEntry

      public CombatEntry(@NotNull @NotNull Mob owner, @NotNull EntityDamageEvent.DamageCause cause, int ticks, float health, float damage) throws IllegalArgumentException
      Constructs a new CombatEntry with no fall damage.
      Parameters:
      owner - Owner of this CombatEntry
      cause - DamageCause of this CombatEntry
      ticks - Number of ticks this CombatEntry has been in combat
      health - Health of the Entity at the time of this CombatEntry before taking getDamage()
      damage - Damage the Entity took in this CombatEntry
      Throws:
      IllegalArgumentException - if DamageCause or Owner is null, or ticks/health/damage is less than 0
    • CombatEntry

      public CombatEntry(@NotNull @NotNull Mob owner, @NotNull EntityDamageEvent.DamageCause cause, int ticks, float health, float damage, float fall) throws IllegalArgumentException
      Constructs a new CombatEntry with no Combat Location.
      Parameters:
      owner - Owner of this CombatEntry
      cause - DamageCause of this CombatEntry
      ticks - Number of ticks this CombatEntry has been in combat
      health - Health of the Entity at the time of this CombatEntry before taking getDamage()
      damage - Damage the Entity took in this CombatEntry
      fall - Last amount of distance the Entity fell in this CombatEntry
      Throws:
      IllegalArgumentException - if DamageCause or Owner is null, or ticks/health/damage/fall is less than 0
    • CombatEntry

      public CombatEntry(@NotNull @NotNull Mob owner, @NotNull EntityDamageEvent.DamageCause cause, int ticks, float health, float damage, float fall, @Nullable @Nullable CombatLocation combatLocation) throws IllegalArgumentException
      Constructs a new CombatEntry with no attacker.
      Parameters:
      owner - Owner of this CombatEntry
      cause - DamageCause of this CombatEntry
      ticks - Number of ticks this CombatEntry has been in combat
      health - Health of the Entity at the time of this CombatEntry before taking getDamage()
      damage - Damage the Entity took in this CombatEntry
      fall - Last amount of distance the Entity fell in this CombatEntry
      combatLocation - Location of this CombatEntry
      Throws:
      IllegalArgumentException - if DamageCause or Owner is null, or ticks/health/damage/fall is less than 0
    • CombatEntry

      public CombatEntry(@NotNull @NotNull Mob owner, @NotNull EntityDamageEvent.DamageCause cause, int ticks, float health, float damage, float fall, @Nullable @Nullable CombatLocation combatLocation, @Nullable @Nullable Entity attacker) throws IllegalArgumentException
      Constructs a new CombatEntry.
      Parameters:
      owner - Owner of this CombatEntry
      cause - DamageCause of this CombatEntry
      ticks - Number of ticks this CombatEntry has been in combat
      health - Health of the Entity at the time of this CombatEntry before taking getDamage()
      damage - Damage the Entity took in this CombatEntry
      fall - Last amount of distance the Entity fell in this CombatEntry
      combatLocation - Location of this CombatEntry
      attacker - Entity that attacked the Entity in this CombatEntry
      Throws:
      IllegalArgumentException - if DamageCause or Owner is null, or ticks/health/damage/fall is less than 0
  • Method Details

    • getCause

      Fetches the cause of the damage in this CombatEntry.
      Returns:
      DamageCause of this CombatEntry
    • getCombatTime

      @Deprecated public int getCombatTime()
      Deprecated.
      As of Minecraft 1.20, no longer stored in CombatEntry
      Fetches how long getOwner() was in combat, in ticks.
      Returns:
      Duration of Combat, in ticks
    • getOwner

      @NotNull public @NotNull Mob getOwner()
      Fetches the owner of this CombatEntry.
      Returns:
      CombatEntry Owner
    • getDamage

      public float getDamage()
      Fetches how much damage this Entity took.
      Returns:
      Damage taken before dying
    • getHealthBeforeDamage

      @Deprecated public float getHealthBeforeDamage()
      Deprecated.
      As of Minecraft 1.20, no longer stored in CombatEntry
      Fetches the health of this Entity would have had before taking damage.
      Returns:
      Health of entity before damage
    • getHealthAfterDamage

      public float getHealthAfterDamage()
      Fetches how much health the entity has had after taking damage.
      Returns:
      Health of entity after damage
    • getLocation

      @Nullable public @Nullable CombatLocation getLocation()
      Fetches the type of preparation this CombatEntry was for. May be null.

      Developers should check hasLocation() before calling this method.
      Returns:
      CombatLocation found, or null if it does not exist
    • hasLocation

      public boolean hasLocation()
      Whether this CombatEntry has a CombatLocation.
      Returns:
      true if CombatLocation exists, else false
    • getAttacker

      @Nullable @Deprecated public @Nullable Entity getAttacker()
      Deprecated.
      As of Minecraft 1.20, no longer stored in CombatEntry
      Fetches the Attacker of this CombatEntry. May be null.

      Developers should check hasAttacker() before calling this method.
      Returns:
      Entity that attacked the Mob that owns this Combat Entry, or null if not found
    • hasAttacker

      public boolean hasAttacker()
      Whether this CombatEntry contains an Entity Attacker.
      Returns:
      true if Entity Attacker exists, else false
    • getFallDistance

      public float getFallDistance()
      Fetches the last amount of distance the Entity fell in this CombatEntry.

      This may return Float.MAX_VALUE if the Damage Cause is EntityDamageEvent.DamageCause.VOID
      Returns:
      Fall Distance
    • builder

      public static CombatEntry.Builder builder()
      Creates a new Builder for a CombatEntry.
      Returns:
      Builder Class