Class MobSpawnEvent.PositionCheck
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.entity.EntityEvent
net.neoforged.neoforge.event.entity.living.MobSpawnEvent
net.neoforged.neoforge.event.entity.living.MobSpawnEvent.PositionCheck
- Enclosing class:
 - MobSpawnEvent
 
This event is fired when a mob checks for a valid spawn position, after 
Conditions validated here include the following:
SpawnPlacements.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.
 
 These checks are performed by the vanilla methods Mob.checkSpawnRules(net.minecraft.world.level.LevelAccessor, net.minecraft.world.entity.MobSpawnType) and Mob.checkSpawnObstruction(net.minecraft.world.level.LevelReader).
 The logical-and of both methods forms the default result of this event.
 
 This event has a result.
 To change the result of this event, use Event.setResult(net.neoforged.bus.api.Event.Result). Results are interpreted in the following manner:
 
- Allow - The position will be accepted, and the spawn process will continue.
 - Default - The position will be accepted if 
Mob.checkSpawnRules(net.minecraft.world.level.LevelAccessor, net.minecraft.world.entity.MobSpawnType)andMob.checkSpawnObstruction(net.minecraft.world.level.LevelReader)are both true. - Deny - The position will not be accepted. The spawn process will abort, and further events will not be called.
 
- API Note:
 - This event fires after Spawn Placement checks, which are the primary set of spawn checks.
 
- 
Nested Class Summary
Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.living.MobSpawnEvent
MobSpawnEvent.AllowDespawn, MobSpawnEvent.FinalizeSpawn, MobSpawnEvent.PositionCheck, MobSpawnEvent.SpawnPlacementCheckNested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.SizeNested classes/interfaces inherited from class net.neoforged.bus.api.Event
net.neoforged.bus.api.Event.HasResult, net.neoforged.bus.api.Event.Result - 
Field Summary
Fields - 
Constructor Summary
ConstructorsConstructorDescriptionPositionCheck(Mob mob, ServerLevelAccessor level, MobSpawnType spawnType, @Nullable BaseSpawner spawner)  - 
Method Summary
Modifier and TypeMethodDescription@Nullable BaseSpawnerRetrieves the underlyingBaseSpawnerinstance if this mob was created by a Mob Spawner of some form.Retrieves the type of mob spawn that is happening.Methods inherited from class net.neoforged.neoforge.event.entity.living.MobSpawnEvent
getEntity, getLevel, getX, getY, getZMethods inherited from class net.neoforged.bus.api.Event
getResult, hasResult, setResult 
- 
Field Details
- 
spawner
 - 
spawnType
 
 - 
 - 
Constructor Details
- 
PositionCheck
public PositionCheck(Mob mob, ServerLevelAccessor level, MobSpawnType spawnType, @Nullable @Nullable BaseSpawner spawner)  
 - 
 - 
Method Details
- 
getSpawner
Retrieves the underlyingBaseSpawnerinstance if this mob was created by a Mob Spawner of some form. This is always null unlessgetSpawnType()isMobSpawnType.SPAWNER, and may still be null even then.- Returns:
 - The BaseSpawner responsible for triggering the spawn, or null if none is available.
 
 - 
getSpawnType
Retrieves the type of mob spawn that is happening.- Returns:
 - The mob spawn type.
 - See Also:
 
 
 -