Uses of Class
net.minecraftforge.event.entity.living.MobSpawnEvent
-
Uses of MobSpawnEvent in net.minecraftforge.event.entity.living
Modifier and TypeClassDescriptionstatic class
This event is fired fromMob.checkDespawn()
.
It fires once per tick per mob that is attempting to despawn.
It is not fired if the mob is persistent (meaning it may not despawn).static class
This event is fired beforeMob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.MobSpawnType, net.minecraft.world.entity.SpawnGroupData, net.minecraft.nbt.CompoundTag)
is called.
This allows mods to control mob initialization.
In vanilla code, this event is injected by a transformer and not via patch, so calls cannot be traced via call hierarchy (it is not source-visible).static class
This event is fired when a mob checks for a valid spawn position, afterSpawnPlacements.checkSpawnRules(net.minecraft.world.entity.EntityType<T>, net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.entity.MobSpawnType, net.minecraft.core.BlockPos, net.minecraft.util.RandomSource)
has been evaluated.
Conditions validated here include the following: Obstruction - mobs inside blocks or fluids. Pathfinding - if the spawn block is valid for pathfinding. Sea Level - Ocelots check if the position is above sea level. Spawn Block - Ocelots check if the below block is grass or leaves.