Interface LivingEntity
- All Superinterfaces:
Entity, HoverEventSource<HoverEvent.ShowEntity>, SchedulerSource, Sound.Emitter, Sound.Source.Provider
- All Known Subinterfaces:
Ageable, Angerable, Animal, Bat, CaveSpider, Chicken, Cow, Creeper, CubeMob, Damageable, Drowned, Enderman, Endermite, Frostbite, Husk, MagmaCube, Mob, Mooshroom, Pig, Player, Shearable, Sheep, Silverfish, Slime, Spider, SulfurCube, Zombie
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.doublearmor()Returns the armor points reducing incoming damage,0when unarmored.doubleReturns the armor toughness softening the armor falloff on heavy hits.doubleattributeValue(TypedKey<Attribute> attribute) Returns the value of an attribute of this entity: its base, with the modifiers of what it wears and holds, of its effects and of its enchantments applied.booleanRemoves every effect, firing anEntityEffectEventfor each.booleandamage(DamageSource source, float amount) Hurts this entity, running the full pipeline of theCombatService: invulnerability frames, shield, armor, Resistance, enchantments, absorption, events, client packets and death.Returns the running effect of a type, or empty when the entity does not have it.equipment(EquipmentSlot slot) Returns the stack worn or held inslot,ItemStack.EMPTYwhen the slot is empty or the entity has none.intbooleanReturnstrueif the entity has an effect of this type.floatheadYaw()voidheal(float amount) Restores some health, up tomaxHealth().floathealth()booleanisAlive()Returnstruewhen this entity is still in the world and has health left.booleanisDead()Returnstruewhen this entity has run out of health.voidKills this entity outright, bypassing armor, shields, totems and invulnerability.doubleReturns the fraction of knockback ignored, between0(none) and1(immune).floatbooleanremoveEffect(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, execute, executeDelayed, 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
-
attributeValue
Returns the value of an attribute of this entity: its base, with the modifiers of what it wears and holds, of its effects and of its enchantments applied.- Parameters:
attribute- the attribute, for instanceAttributeKeys.ATTACK_DAMAGE- Returns:
- the value of an attribute of this entity: its base, with the modifiers of what it wears and holds, of its effects and of its enchantments applied
- Since:
- 0.1.0
-
armor
double armor()Returns the armor points reducing incoming damage,0when unarmored.- Returns:
- the armor points reducing incoming damage,
0when unarmored - Since:
- 0.1.0
-
armorToughness
double armorToughness()Returns the armor toughness softening the armor falloff on heavy hits.- Returns:
- the armor toughness softening the armor falloff on heavy hits
- Since:
- 0.1.0
-
knockbackResistance
double knockbackResistance()Returns the fraction of knockback ignored, between0(none) and1(immune).- Returns:
- the fraction of knockback ignored, between
0(none) and1(immune) - Since:
- 0.1.0
-
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
Returns the stack worn or held inslot,ItemStack.EMPTYwhen the slot is empty or the entity has none.- Parameters:
slot- the equipment slot- Returns:
- the stack worn or held in
slot,ItemStack.EMPTYwhen the slot is empty or the entity has none - Since:
- 0.1.0
-
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 of theCombatService: invulnerability frames, shield, armor, Resistance, enchantments, absorption, events, client packets and death.- Parameters:
source- the origin of the hitamount- the damage in half-hearts before reduction;<= 0is ignored- Returns:
trueif the hit hurt this entity, even when armor took all of it;falsewhen it was refused or cancelled, absorbed by the invulnerability left by the last hit, or blocked by a shield- Since:
- 0.1.0
-
kill
-
heal
void heal(float amount) Restores some health, up tomaxHealth(). A dead entity is not healed.- Parameters:
amount- the health to restore in half-hearts;<= 0is ignored- Since:
- 0.1.0
-
isDead
boolean isDead()Returnstruewhen this entity has run out of health.- Returns:
truewhen this entity has run out of health- Since:
- 0.1.0
-
isAlive
boolean isAlive()Returnstruewhen this entity is still in the world and has health left.- Returns:
truewhen this entity is still in the world and has health left- Since:
- 0.1.0
-