Interface LivingEntity

All Superinterfaces:
CommandSource, Entity, HoverEventSource<HoverEvent.ShowEntity>, Sound.Emitter, Sound.Source.Provider
All Known Subinterfaces:
Damageable, Player

public interface LivingEntity extends Entity
An entity with health that can be hurt and killed.
Since:
0.1.0
  • Method Details

    • health

      float health()
      Returns:
      the current health in half-hearts, between 0 and maxHealth()
    • setHealth

      void setHealth(float health)
      Parameters:
      health - the health to set, clamped between 0 and maxHealth()
    • maxHealth

      float maxHealth()
      Returns:
      the health ceiling in half-hearts
    • absorptionAmount

      float absorptionAmount()
      Returns:
      the yellow absorption hearts soaking damage before health() does
    • setAbsorptionAmount

      void setAbsorptionAmount(float absorption)
      Parameters:
      absorption - the absorption hearts to set; negative values are treated as 0
    • armor

      default double armor()
      Returns:
      the armor points reducing incoming damage, 0 when unarmored
    • armorToughness

      default double armorToughness()
      Returns:
      the armor toughness softening the armor falloff on heavy hits
    • knockbackResistance

      default double knockbackResistance()
      Returns:
      the fraction of knockback ignored, between 0 (none) and 1 (immune)
    • fireTicks

      int fireTicks()
      Returns:
      the remaining ticks this entity keeps burning, 0 when not on fire
    • setFireTicks

      void setFireTicks(int ticks)
      Parameters:
      ticks - the burning ticks to set; 0 extinguishes the entity
    • damage

      default boolean damage(DamageSource source, float amount)
      Hurts this entity, running the full pipeline: invulnerability frames, armor, absorption, events, client packets and death.
      Parameters:
      source - the origin of the hit
      amount - the damage in half-hearts before reduction; <= 0 is ignored
      Returns:
      true if health or absorption was actually removed
      Since:
      0.1.0
    • kill

      default void kill(@Nullable Entity killer)
      Kills this entity outright, bypassing armor and invulnerability.
      Parameters:
      killer - the entity credited with the kill, or null
      Since:
      0.1.0
    • heal

      default void heal(float amount)
      Parameters:
      amount - the health to restore in half-hearts; <= 0 is ignored
      Since:
      0.1.0
    • isDead

      default boolean isDead()
      Returns:
      true when this entity has run out of health
    • isAlive

      default boolean isAlive()
      Returns:
      true when this entity is still in the world and has health left