Class FinalizeSpawnEvent

java.lang.Object
net.neoforged.bus.api.Event
All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent

public class FinalizeSpawnEvent extends MobSpawnEvent implements net.neoforged.bus.api.ICancellableEvent
This event is fired before Mob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.MobSpawnType, net.minecraft.world.entity.SpawnGroupData) is called.
This allows mods to control mob initialization.
In vanilla code, this event is injected by a transformer and not via patch, so calls cannot be traced via call hierarchy (it is not source-visible).

Canceling this event will result in Mob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.MobSpawnType, net.minecraft.world.entity.SpawnGroupData) not being called, and the returned value always being null, instead of propagating the SpawnGroupData.
The entity will still be spawned. If you want to prevent the spawn, use setSpawnCancelled(boolean), which will cause Forge to prevent the spawn.

This event is fired on NeoForge.EVENT_BUS, and is only fired on the logical server.

See Also:
  • invalid reference
    EventHooks#onFinalizeSpawn