Class PlayerRespawnPositionEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.entity.EntityEvent
net.neoforged.neoforge.event.entity.living.LivingEvent
net.neoforged.neoforge.event.entity.player.PlayerEvent
net.neoforged.neoforge.event.entity.player.PlayerRespawnPositionEvent
Fired by
before the server respawns a player.
This may be used to change the
is called.
invalid reference
PlayerList#respawn(ServerPlayer, boolean)
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)
This event is only fired on the logical server.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.player.PlayerEvent
PlayerEvent.BreakSpeed, PlayerEvent.Clone, PlayerEvent.HarvestCheck, PlayerEvent.ItemCraftedEvent, PlayerEvent.ItemSmeltedEvent, PlayerEvent.LoadFromFile, PlayerEvent.NameFormat, PlayerEvent.PlayerChangedDimensionEvent, PlayerEvent.PlayerChangeGameModeEvent, PlayerEvent.PlayerLoggedInEvent, PlayerEvent.PlayerLoggedOutEvent, PlayerEvent.PlayerRespawnEvent, PlayerEvent.SaveToFile, PlayerEvent.StartTracking, PlayerEvent.StopTracking, PlayerEvent.TabListNameFormat
Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.living.LivingEvent
LivingEvent.LivingJumpEvent, LivingEvent.LivingVisibilityEvent
Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.Size
-
Field Summary
Modifier and TypeFieldDescriptionprivate boolean
private DimensionTransition
private final boolean
private final DimensionTransition
-
Constructor Summary
ConstructorDescriptionPlayerRespawnPositionEvent
(ServerPlayer player, DimensionTransition dimensionTransition, boolean fromEndFight) -
Method Summary
Modifier and TypeMethodDescriptionboolean
If the respawn position of the original player will be copied to the fresh player viaServerPlayer.copyRespawnPosition(ServerPlayer)
.boolean
void
setCopyOriginalSpawnPosition
(boolean copyOriginalSpawnPosition) Changes if the original player's respawn position will be copied to the fresh player viaServerPlayer.copyRespawnPosition(ServerPlayer)
.void
setDimensionTransition
(DimensionTransition dimensionTransition) Set the dimension transition for where the player will respawnvoid
setRespawnLevel
(ResourceKey<Level> respawnLevelResourceKey) Set the level the player will respawn into using aResourceKey
.Methods inherited from class net.neoforged.neoforge.event.entity.player.PlayerEvent
getEntity
-
Field Details
-
dimensionTransition
-
originalDimensionTransition
-
fromEndFight
private final boolean fromEndFight -
copyOriginalSpawnPosition
private boolean copyOriginalSpawnPosition
-
-
Constructor Details
-
PlayerRespawnPositionEvent
public PlayerRespawnPositionEvent(ServerPlayer player, DimensionTransition dimensionTransition, boolean fromEndFight)
-
-
Method Details
-
getDimensionTransition
- Returns:
- The dimension transition for where the player will respawn
-
setDimensionTransition
Set the dimension transition for where the player will respawn- Parameters:
dimensionTransition
- The new dimension transition.
-
setRespawnLevel
Set the level the player will respawn into using aResourceKey
.- Parameters:
respawnLevelResourceKey
- TheResourceKey
of the level to respawn into.
-
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 viaServerPlayer.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 viaServerPlayer.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:
-