Class ServerLivingEntityEvents

java.lang.Object
net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents

public final class ServerLivingEntityEvents extends Object
Various server-side only events related to living entities.
  • Field Details

    • ALLOW_DAMAGE

      public static final Event<ServerLivingEntityEvents.AllowDamage> ALLOW_DAMAGE
      An event that is called when a living entity is going to take damage. This is fired from LivingEntity.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

      public static final Event<ServerLivingEntityEvents.AllowDeath> 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 (with LivingEntity.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

      public static final Event<ServerLivingEntityEvents.AfterDeath> AFTER_DEATH
      An event that is called when a living entity dies.
    • MOB_CONVERSION

      public static final Event<ServerLivingEntityEvents.MobConversion> 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.