Interface LivingEntity
- All Superinterfaces:
Entity, HoverEventSource<HoverEvent.ShowEntity>, SchedulerSource, Sound.Emitter, Sound.Source.Provider
- All Known Subinterfaces:
Damageable, Mob, Player
An entity with health that can be hurt and killed.
- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptionfloatReturns a snapshot of the running effects.booleanaddEffect(MobEffectInstance effect) Applies a status effect.default doublearmor()default doublebooleanRemoves every effect, firing anEntityEffectEventfor each.default booleandamage(DamageSource source, float amount) Hurts this entity, running the full pipeline: invulnerability frames, armor, absorption, events, client packets and death.Returns the running effect of a type, or empty when the entity does not have it.default ItemStackequipment(EquipmentSlot slot) intbooleanReturnstrueif the entity has an effect of this type.floatheadYaw()default voidheal(float amount) floathealth()default booleanisAlive()default booleanisDead()default voidKills this entity outright, bypassing armor and invulnerability.default doublefloatbooleanremoveEffect(TypedKey<MobEffect> type) Removes an effect.voidsetAbsorptionAmount(float absorption) voidsetFireTicks(int ticks) voidsetHeadYaw(float headYaw) voidsetHealth(float health) Methods inherited from interface Entity
chunk, displayName, entityId, isRemoved, location, remove, server, teleport, teleport, teleport, type, uuid, worldMethods inherited from interface HoverEventSource
asHoverEvent, asHoverEventMethods inherited from interface SchedulerSource
execute, executeDelayed, isOwnedByCurrentThreadMethods 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
-
headYaw
float headYaw()- Returns:
- the current head yaw
-
setHeadYaw
void setHeadYaw(float headYaw) - Parameters:
headYaw- the head yaw to set
-
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
-
equipment
- Parameters:
slot- the equipment slot- Returns:
- the stack worn or held in
slot,ItemStack.EMPTYwhen the slot is empty or the entity has none
-
addEffect
Applies a status effect. When the entity already has an effect of the same type, the two are merged the vanilla way: a higher amplifier replaces it, and an equal one only refreshes a longer duration. Fires anEntityEffectEvent.- Parameters:
effect- the effect to apply- Returns:
trueif the effects of the entity changed- Since:
- 0.1.0
-
effect
Returns the running effect of a type, or empty when the entity does not have it.- Parameters:
type- the effect, for instanceMobEffectKeys.SPEED- Returns:
- the running effect of a type, or empty when the entity does not have it
- Since:
- 0.1.0
-
hasEffect
-
activeEffects
Collection<MobEffectInstance> activeEffects()Returns a snapshot of the running effects.- Returns:
- a snapshot of the running effects
- Since:
- 0.1.0
-
removeEffect
Removes an effect. Fires anEntityEffectEvent.- Parameters:
type- the effect to remove- Returns:
trueif the entity had the effect and it was removed- Since:
- 0.1.0
-
clearEffects
boolean clearEffects()Removes every effect, firing anEntityEffectEventfor each.- Returns:
trueif at least one effect was removed- Since:
- 0.1.0
-
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
-