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.