Class MobDespawnEvent

java.lang.Object
net.neoforged.bus.api.Event

public class MobDespawnEvent extends MobSpawnEvent
This event is fired from Mob.checkDespawn().
It fires once per tick per mob that is attempting to despawn.

It is fired for all entities, including persistent entities. Additionally, it may be used to keep mobs from despawning in peaceful mode.

This event is only fired on the logical server.

See Also:
  • Mob.checkDespawn()
  • Field Details

  • Constructor Details

    • MobDespawnEvent

      @Internal public MobDespawnEvent(net.minecraft.world.entity.Mob mob, net.minecraft.world.level.ServerLevelAccessor level)
  • Method Details

    • setResult

      public void setResult(MobDespawnEvent.Result result)
      Changes the result of this event.
    • getResult

      public MobDespawnEvent.Result getResult()
      Returns the result of this event, which controls if the despawn will occur.
      Returns:
      the result of this event, which controls if the despawn will occur