Class ServerLivingEntityEvents
java.lang.Object
net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents
Various server-side only events related to living entities.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
static interface
static interface
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Event
<ServerLivingEntityEvents.AfterDeath> An event that is called when a living entity dies.static final Event
<ServerLivingEntityEvents.AllowDamage> An event that is called when a living entity is going to take damage.static final Event
<ServerLivingEntityEvents.AllowDeath> An event that is called when an entity takes fatal damage.static final Event
<ServerLivingEntityEvents.MobConversion> An event that is called when a mob has been converted to another type. -
Method Summary
-
Field Details
-
ALLOW_DAMAGE
An event that is called when a living entity is going to take damage. This is fired fromLivingEntity.damage(net.minecraft.entity.damage.DamageSource, float)
, before armor or any other mitigation are applied. Mods can cancel this to prevent the damage entirely. -
ALLOW_DEATH
An event that is called when an entity takes fatal damage.Mods can cancel this to keep the entity alive.
Vanilla checks for entity health
<= 0
each tick (withLivingEntity.isDead()
), and kills if true - so the entity will still die next tick if this event is cancelled. It's assumed that the listener will do something to prevent this, for example, if the entity is a player:- a minigame mod teleporting the player into a 'respawn room' and setting their health to 20.0
- a mod that changes death mechanics switching the player over to the mod's play-mode, where death doesn't apply
-
AFTER_DEATH
An event that is called when a living entity dies. -
MOB_CONVERSION
An event that is called when a mob has been converted to another type.When this event is called, the old instance has not yet been discarded, and the new one has not yet been spawned. Mods may use this event to copy some of the old entity's data to the converted one.
This event only handles cases where the entity type changes, requiring a new instance. Notably it does not cover mooshrooms changing color from lightning, creepers getting charged, or wolves being tamed.
-