Interface PlayerRespawnCallback


public interface PlayerRespawnCallback
Represents a callback for when a ServerPlayer is respawned.

This occurs when a player dies, or changes dimensions, such as returning to the overworld from the end.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final net.fabricmc.fabric.api.event.Event<PlayerRespawnCallback>
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onRespawn(net.minecraft.server.level.ServerPlayer newPlayer, net.minecraft.server.level.ServerPlayer oldPlayer, boolean isAlive)
    Called when a player respawns.
  • Field Details

  • Method Details

    • onRespawn

      void onRespawn(net.minecraft.server.level.ServerPlayer newPlayer, net.minecraft.server.level.ServerPlayer oldPlayer, boolean isAlive)
      Called when a player respawns.

      Note the player can be repositioned.

      When this method is called, newPlayer will be at its spawn position.

      The player may be repositioned by callbacks to change where it respawns. The oldPlayer's coordinates and world will be the same as before the respawn,

      Player's data has been copied from the oldPlayer to newPlayer. The actual copied data depends on various factors such as the value of isAlive or of the keepInventory GameRule.

      Parameters:
      newPlayer - The new ServerPlayer that will be spawned.
      oldPlayer - The old ServerPlayer that is being removed.
      isAlive - Whether the old player is still alive.