Skip to main content
Version: 26.1.x

Entity Events

dev.architectury.event.events.common.EntityEvent

Events about entities: dying, taking damage, spawning, being added to the world, moving between chunk sections, and being tamed.

Events

EventListener methodReturns
LIVING_DEATHdie(LivingEntity, DamageSource)EventResult - interrupt to cancel the death.
LIVING_HURThurt(LivingEntity, DamageSource, float amount)EventResult - interrupt to cancel the damage.
LIVING_CHECK_SPAWNcanSpawn(LivingEntity, LevelAccessor, double x, double y, double z, EntitySpawnReason, BaseSpawner)EventResult - set an outcome to override whether it may spawn.
ADDadd(Entity, Level)EventResult - interrupt to prevent the entity being added.
ENTER_SECTIONenterSection(Entity, int sectionX, sectionY, sectionZ, int prevX, prevY, prevZ)void (notification).
ANIMAL_TAMEtame(Animal, Player)EventResult - interrupt to cancel the taming.
note

LIVING_HURT lets you cancel damage, but you currently cannot change the damage amount. LIVING_CHECK_SPAWN concerns natural/spawner spawning and worldgen; the spawner argument may be null. ANIMAL_TAME only fires for vanilla tamable mobs.

Examples

Make a custom boss immune to drowning:

EntityEvent.LIVING_HURT.register((entity, source, amount) -> {
if (entity instanceof MyBossEntity && source.is(DamageTypes.DROWN)) {
return EventResult.interruptFalse(); // cancel the damage
}
return EventResult.pass();
});

Prevent zombies from spawning in a region:

EntityEvent.LIVING_CHECK_SPAWN.register((entity, world, x, y, z, type, spawner) -> {
if (entity instanceof Zombie && isProtected(x, z)) {
return EventResult.interruptFalse();
}
return EventResult.pass();
});