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
-
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. -
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.
-