Interface LivingEntity
- All Superinterfaces:
CommandSource, Entity, HoverEventSource<HoverEvent.ShowEntity>, Sound.Emitter, Sound.Source.Provider
- All Known Subinterfaces:
Damageable, Player
An entity with health that can be hurt and killed.
- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptionfloatdefault doublearmor()default doubledefault booleandamage(DamageSource source, float amount) Hurts this entity, running the full pipeline: invulnerability frames, armor, absorption, events, client packets and death.intdefault voidheal(float amount) floathealth()default booleanisAlive()default booleanisDead()default voidKills this entity outright, bypassing armor and invulnerability.default doublefloatvoidsetAbsorptionAmount(float absorption) voidsetFireTicks(int ticks) voidsetHealth(float health) Methods inherited from interface CommandSource
executor, sender, serverMethods inherited from interface Entity
chunk, displayName, entityId, isRemoved, location, remove, teleport, teleport, teleport, teleport, type, uuid, worldMethods inherited from interface HoverEventSource
asHoverEvent, asHoverEventMethods inherited from interface Sound.Source.Provider
soundSource
-
Method Details
-
health
float health()- Returns:
- the current health in half-hearts, between
0andmaxHealth()
-
setHealth
void setHealth(float health) - Parameters:
health- the health to set, clamped between0andmaxHealth()
-
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 as0
-
armor
default double armor()- Returns:
- the armor points reducing incoming damage,
0when 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) and1(immune)
-
fireTicks
int fireTicks()- Returns:
- the remaining ticks this entity keeps burning,
0when not on fire
-
setFireTicks
void setFireTicks(int ticks) - Parameters:
ticks- the burning ticks to set;0extinguishes the entity
-
damage
Hurts this entity, running the full pipeline: invulnerability frames, armor, absorption, events, client packets and death.- Parameters:
source- the origin of the hitamount- the damage in half-hearts before reduction;<= 0is ignored- Returns:
trueif health or absorption was actually removed- Since:
- 0.1.0
-
kill
-
heal
default void heal(float amount) - Parameters:
amount- the health to restore in half-hearts;<= 0is ignored- Since:
- 0.1.0
-
isDead
default boolean isDead()- Returns:
truewhen this entity has run out of health
-
isAlive
default boolean isAlive()- Returns:
truewhen this entity is still in the world and has health left
-