Class PlayerRespawnPositionEvent


public class PlayerRespawnPositionEvent extends PlayerEvent
Fired by
invalid reference
PlayerList#respawn(ServerPlayer, boolean)
before the server respawns a player. This may be used to change the ServerLevel the player respawns in, as well as their respawn position. This event is fired after
invalid reference
BlockState#getRespawnPosition(EntityType, LevelReader, BlockPos, float, LivingEntity)
is called.

This event is only fired on the logical server.

  • Field Details

    • dimensionTransition

      private DimensionTransition dimensionTransition
    • originalDimensionTransition

      private final DimensionTransition originalDimensionTransition
    • fromEndFight

      private final boolean fromEndFight
    • copyOriginalSpawnPosition

      private boolean copyOriginalSpawnPosition
  • Constructor Details

  • Method Details

    • getDimensionTransition

      public DimensionTransition getDimensionTransition()
      Returns:
      The dimension transition for where the player will respawn
    • setDimensionTransition

      public void setDimensionTransition(DimensionTransition dimensionTransition)
      Set the dimension transition for where the player will respawn
      Parameters:
      dimensionTransition - The new dimension transition.
    • setRespawnLevel

      public void setRespawnLevel(ResourceKey<Level> respawnLevelResourceKey)
      Set the level the player will respawn into using a ResourceKey.
      Parameters:
      respawnLevelResourceKey - The ResourceKey of the level to respawn into.
    • getOriginalDimensionTransition

      public DimensionTransition getOriginalDimensionTransition()
      Returns:
      The dimension transition the server originally intended to respawn the player to.
    • copyOriginalSpawnPosition

      public boolean copyOriginalSpawnPosition()
      If the respawn position of the original player will be copied to the fresh player via ServerPlayer.copyRespawnPosition(ServerPlayer).

      This defaults to true if the original dimension transition was not missing a respawn block.

      This has no impact on the selected position for the current respawn, but controls if the player will (for example) retain their bed as their set respawn position.

    • setCopyOriginalSpawnPosition

      public void setCopyOriginalSpawnPosition(boolean copyOriginalSpawnPosition)
      Changes if the original player's respawn position will be copied to the fresh player via ServerPlayer.copyRespawnPosition(ServerPlayer).

      If you wish to modify the set respawn position of the fresh player (for future respawns, not the current respawn), you can change the respawn position of the current player and set this value to true.

      See Also:
    • isFromEndFight

      public boolean isFromEndFight()
      Returns:
      Whether the respawn was triggered by the player jumping into the End return portal.
      See Also: