类 MobSpawnEvent

java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.event.entity.EntityEvent
net.minecraftforge.event.entity.living.MobSpawnEvent
直接已知子类:
MobSpawnEvent.AllowDespawn, MobSpawnEvent.FinalizeSpawn, MobSpawnEvent.PositionCheck

public abstract class MobSpawnEvent extends EntityEvent
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:

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, MobSpawnEvent.FinalizeSpawn is fired, which performs initialization on the newly-spawned entity.
Finally, if the spawn was not cancelled via MobSpawnEvent.FinalizeSpawn.setSpawnCancelled(boolean), then

引用无效
EntityJoinLevelEvent
is fired as the entity enters the world.

MobSpawnEvent.AllowDespawn is not related to the mob spawn event flow, as it fires when a despawn is attempted.

  • 字段详细资料

    • level

      private final ServerLevelAccessor level
    • x

      private final double x
    • y

      private final double y
    • z

      private final double z
  • 构造器详细资料

    • MobSpawnEvent

      @Internal protected MobSpawnEvent(Mob mob, ServerLevelAccessor level, double x, double y, double z)
  • 方法详细资料

    • getEntity

      public Mob getEntity()
      覆盖:
      getEntity 在类中 EntityEvent
    • getLevel

      public ServerLevelAccessor 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