Class MobSpawnEvent
java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.event.entity.EntityEvent
net.minecraftforge.event.entity.living.MobSpawnEvent
- Direct Known Subclasses:
MobSpawnEvent.AllowDespawn
,MobSpawnEvent.FinalizeSpawn
The subclasses of this event are fired whenever a mob performs a spawning-related action.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
This event is fired fromMob.checkDespawn()
.
It fires once per tick per mob that is attempting to despawn.
It is not fired if the mob is persistent (meaning it may not despawn).static class
This event is fired beforeMob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.MobSpawnType, net.minecraft.world.entity.SpawnGroupData, net.minecraft.nbt.CompoundTag)
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).Nested classes/interfaces inherited from class net.minecraftforge.event.entity.EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.Size
Nested classes/interfaces inherited from class net.minecraftforge.eventbus.api.Event
net.minecraftforge.eventbus.api.Event.HasResult, net.minecraftforge.eventbus.api.Event.Result
-
Field Summary
Modifier and TypeFieldDescriptionprivate final ServerLevelAccessor
private final double
private final double
private final double
-
Constructor Summary
ConstructorDescriptionMobSpawnEvent
(Mob mob, ServerLevelAccessor level, double x, double y, double z) -
Method Summary
Methods inherited from class net.minecraftforge.eventbus.api.Event
getListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setCanceled, setPhase, setResult
-
Field Details
-
level
-
x
private final double x -
y
private final double y -
z
private final double z
-
-
Constructor Details
-
MobSpawnEvent
-
-
Method Details
-
getEntity
- Overrides:
getEntity
in classEntityEvent
-
getLevel
- Returns:
- The level relating to the mob spawn action
-
getX
public double getX()- Returns:
- The x-coordinate relating to the mob spawn action
-
getY
public double getY()- Returns:
- The y-coordinate relating to the mob spawn action
-
getZ
public double getZ()- Returns:
- The z-coordinate relating to the mob spawn action
-