类 MobSpawnEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.entity.EntityEvent
net.neoforged.neoforge.event.entity.living.MobSpawnEvent
This class holds all events relating to the entire flow of mob spawns.
Currently, the events have the following flow for any given mob spawn:
Currently, the events have the following flow for any given mob spawn:
Before the spawn is attempted MobSpawnEvent.SpawnPlacementCheck
is fired, to determine if the spawn may occur based on mob-specific rules.
After the entity is created MobSpawnEvent.PositionCheck
is fired, to determine if the selected position is legal for the entity.
If both checks succeeded,
is fired, which performs initialization on the newly-spawned entity.引用无效
FinalizeSpawn
Finally, if the spawn was not cancelled via
, then 引用无效
FinalizeSpawn#setSpawnCancelled
EntityJoinLevelEvent
is fired as the entity enters the world.
is not related to the mob spawn event flow, as it fires when a despawn is attempted.引用无效
AllowDespawn
-
嵌套类概要
嵌套类修饰符和类型类说明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.EntitySpawnReason, 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.static class
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.从类继承的嵌套类/接口 net.neoforged.neoforge.event.entity.EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.Size
-
字段概要
字段修饰符和类型字段说明private final ServerLevelAccessor
private final double
private final double
private final double
-
构造器概要
构造器限定符构造器说明protected
MobSpawnEvent
(Mob mob, ServerLevelAccessor level, double x, double y, double z) -
方法概要
-
字段详细资料
-
level
-
x
private final double x -
y
private final double y -
z
private final double z
-
-
构造器详细资料
-
MobSpawnEvent
-
-
方法详细资料
-
getEntity
- 覆盖:
getEntity
在类中EntityEvent
-
getLevel
- 返回:
- The level relating to the mob spawn action
-
getX
public double getX()- 返回:
- The x-coordinate relating to the mob spawn action
-
getY
public double getY()- 返回:
- The y-coordinate relating to the mob spawn action
-
getZ
public double getZ()- 返回:
- The z-coordinate relating to the mob spawn action
-