Class MobSpawnEvent.SpawnPlacementCheck
java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.event.entity.living.MobSpawnEvent.SpawnPlacementCheck
- Enclosing class:
- MobSpawnEvent
public static class MobSpawnEvent.SpawnPlacementCheck
extends net.minecraftforge.eventbus.api.Event
This event is fired when Spawn Placements (aka Spawn Rules) are checked, before a mob attempts to spawn.
Spawn Placement checks include light levels, slime chunks, grass blocks for animals, and others in the same vein.
The purpose of this event is to permit runtime changes to any or all spawn placement logic without having to wrap the placement for each entity.
Spawn Placement checks include light levels, slime chunks, grass blocks for animals, and others in the same vein.
The purpose of this event is to permit runtime changes to any or all spawn placement logic without having to wrap the placement for each entity.
 This event has a result.
 To change the result of this event, use Event.setResult(net.minecraftforge.eventbus.api.Event.Result). Results are interpreted in the following manner:
 
- Allow - The check will succeed, and the spawn process will continue.
- Default - The value of the vanilla check will be used to determine success.
- Deny - The check will fail, and the spawn process will abort.
 This event is not fired for mob spawners which utilize CustomSpawnRules, as they do not check spawn placements.
- See Also:
- API Note:
- If your modifications are for a single entity, and do not vary at runtime, use SpawnPlacementRegisterEvent.
- 
Nested Class SummaryNested classes/interfaces inherited from class net.minecraftforge.eventbus.api.Eventnet.minecraftforge.eventbus.api.Event.HasResult, net.minecraftforge.eventbus.api.Event.Result
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprivate final booleanprivate final EntityType<?>private final ServerLevelAccessorprivate final BlockPosprivate final RandomSourceprivate final MobSpawnType
- 
Constructor SummaryConstructorsConstructorDescriptionSpawnPlacementCheck(EntityType<?> entityType, ServerLevelAccessor level, MobSpawnType spawnType, BlockPos pos, RandomSource random, boolean defaultResult) Internal.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanThe default vanilla result is useful if an additional check wants to forceEvent.Result.ALLOWonly if the vanilla check would succeed.EntityType<?>getLevel()getPos()In all vanilla cases, this is equal toLevelAccessor.getRandom().Retrieves the type of mob spawn that is happening.Methods inherited from class net.minecraftforge.eventbus.api.EventgetListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setCanceled, setPhase, setResult
- 
Field Details- 
entityType
- 
level
- 
spawnType
- 
pos
- 
random
- 
defaultResultprivate final boolean defaultResult
 
- 
- 
Constructor Details- 
SpawnPlacementCheck@Internal public SpawnPlacementCheck(EntityType<?> entityType, ServerLevelAccessor level, MobSpawnType spawnType, BlockPos pos, RandomSource random, boolean defaultResult) Internal.
 
- 
- 
Method Details- 
getEntityType- Returns:
- The type of entity that checks are being performed for.
 
- 
getLevel- Returns:
- The level relating to the mob spawn action
 
- 
getSpawnTypeRetrieves the type of mob spawn that is happening.- Returns:
- The mob spawn type.
- See Also:
 
- 
getPos- Returns:
- The position where checks are being evaluated.
 
- 
getRandomIn all vanilla cases, this is equal toLevelAccessor.getRandom().- Returns:
- The random source being used.
 
- 
getDefaultResultpublic boolean getDefaultResult()The default vanilla result is useful if an additional check wants to forceEvent.Result.ALLOWonly if the vanilla check would succeed.- Returns:
- The result of the vanilla spawn placement check.
 
 
-