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.
This event is only fired on the logical server.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.living.MobSpawnEvent
MobSpawnEvent.PositionCheck, MobSpawnEvent.SpawnPlacementCheck
Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.Size
-
Field Summary
-
Constructor Summary
ConstructorDescriptionPositionCheck
(Mob mob, ServerLevelAccessor level, MobSpawnType spawnType, @Nullable BaseSpawner spawner) -
Method Summary
Modifier and TypeMethodDescriptionReturns the result of this event, which controls if the position check will succeed.@Nullable BaseSpawner
Retrieves the underlyingBaseSpawner
instance if this mob was created by a Mob Spawner of some form.Retrieves the type of mob spawn that is happening.void
Changes the result of this event.
-
Field Details
-
spawner
-
spawnType
-
result
-
-
Constructor Details
-
PositionCheck
public PositionCheck(Mob mob, ServerLevelAccessor level, MobSpawnType spawnType, @Nullable @Nullable BaseSpawner spawner)
-
-
Method Details
-
getSpawner
Retrieves the underlyingBaseSpawner
instance 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:
-
setResult
Changes the result of this event. -
getResult
Returns the result of this event, which controls if the position check will succeed.- Returns:
- the result of this event, which controls if the position check will succeed
-