Class ServerLivingEntityEvents
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
static interface
static interface
static interface
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Event
<ServerLivingEntityEvents.AfterDamage> An event that is called after an entity is damaged.static 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.server.world.ServerWorld, net.minecraft.entity.damage.DamageSource, float)
, before armor or any other mitigation are applied. Mods can cancel this to prevent the damage entirely. -
AFTER_DAMAGE
An event that is called after an entity is damaged. This is fired fromLivingEntity.damage(net.minecraft.server.world.ServerWorld, net.minecraft.entity.damage.DamageSource, float)
after damage is applied, or after that damage was blocked by a shield.The base damage taken is the damage initially applied to the entity. Damage taken is the amount of damage the entity actually took, after effects such as shields and extra freezing damage are applied. Damage taken does NOT include damage reduction from armor and enchantments.
This event is not fired if the entity was killed by the damage.
-
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.
-