Interface Damageable

All Superinterfaces:
Audience, CommandSender, Entity, HoverEventSource<HoverEvent.ShowEntity>, Metadatable, Nameable, Permissible, PersistentDataHolder, Pointered, ServerOperator, Sound.Emitter
All Known Subinterfaces:
AbstractHorse, AbstractSkeleton, AbstractVillager, Ageable, Allay, Ambient, Animals, ArmorStand, Axolotl, Bat, Bee, Blaze, Breedable, Camel, Cat, CaveSpider, ChestedHorse, Chicken, Cod, CollarColorable, ComplexLivingEntity, Cow, Creature, Creeper, Dolphin, Donkey, Drowned, ElderGuardian, EnderDragon, EnderDragonPart, Enderman, Endermite, Enemy, Evoker, Fish, Flying, Fox, Frog, Ghast, Giant, GlowSquid, Goat, Golem, Guardian, Hoglin, Horse, HumanEntity, Husk, Illager, Illusioner, IronGolem, LivingEntity, Llama, MagmaCube, Mob, Monster, Mule, MushroomCow, NPC, Ocelot, Panda, Parrot, Phantom, Pig, Piglin, PiglinAbstract, PiglinBrute, PigZombie, Pillager, Player, PolarBear, PufferFish, Rabbit, Raider, RangedEntity, Ravager, Salmon, SchoolableFish, Sheep, Shulker, Silverfish, Skeleton, SkeletonHorse, Slime, Snowman, Spellcaster, Spider, Squid, Steerable, Stray, Strider, Tadpole, Tameable, TraderLlama, TropicalFish, Turtle, Vex, Villager, Vindicator, WanderingTrader, Warden, WaterMob, Witch, Wither, WitherSkeleton, Wolf, Zoglin, Zombie, ZombieHorse, ZombieVillager

public interface Damageable extends Entity
Represents an Entity that has health and can take damage.
  • Method Details

    • damage

      void damage(double amount)
      Deals the given amount of damage to this entity.
      Parameters:
      amount - Amount of damage to deal
    • damage

      void damage(double amount, @Nullable @Nullable Entity source)
      Deals the given amount of damage to this entity, from a specified entity.
      Parameters:
      amount - Amount of damage to deal
      source - Entity which to attribute this damage from
    • getHealth

      double getHealth()
      Gets the entity's health from 0 to getMaxHealth(), where 0 is dead.
      Returns:
      Health represented from 0 to max
    • setHealth

      void setHealth(double health)
      Sets the entity's health from 0 to getMaxHealth(), where 0 is dead.
      Parameters:
      health - New health represented from 0 to max
      Throws:
      IllegalArgumentException - Thrown if the health is < 0 or > getMaxHealth()
    • getAbsorptionAmount

      double getAbsorptionAmount()
      Gets the entity's absorption amount.
      Returns:
      absorption amount from 0
    • setAbsorptionAmount

      void setAbsorptionAmount(double amount)
      Sets the entity's absorption amount.
      Parameters:
      amount - new absorption amount from 0
      Throws:
      IllegalArgumentException - thrown if health is < 0 or non-finite.
    • getMaxHealth

      @Deprecated double getMaxHealth()
      Gets the maximum health this entity has.
      Returns:
      Maximum health
    • setMaxHealth

      @Deprecated void setMaxHealth(double health)
      Sets the maximum health this entity can have.

      If the health of the entity is above the value provided it will be set to that value.

      Note: An entity with a health bar (Player, EnderDragon, Wither, etc...} will have their bar scaled accordingly.

      Parameters:
      health - amount of health to set the maximum to
    • resetMaxHealth

      @Deprecated void resetMaxHealth()
      Resets the max health to the original amount.