Contents
- Description
- Nested Class Summary
- Field Summary
- Constructor Summary
- Method Summary
- Field Details
- Constructor Details
- Method Details
- getComponentType()
- copyFrom(Player)
- init(UUID, PlayerRef)
- setNetworkId(int)
- remove()
- moveTo(Ref, double, double, double, ComponentAccessor)
- getPlayerConfigData()
- markNeedsSave()
- applyMovementStates(Ref, SavedMovementStates, MovementStates, ComponentAccessor)
- startClientReadyTimeout()
- handleClientReady(boolean)
- saveConfig(World, Holder, boolean)
- getPlayerConnection()
- getWorldMapTracker()
- getWindowManager()
- getPageManager()
- getHudManager()
- getHotbarManager()
- isFirstSpawn()
- setFirstSpawn(boolean)
- resetManagers(Holder)
- notifyPickupItem(Ref, ItemStack, Vector3d, ComponentAccessor)
- isOverrideBlockPlacementRestrictions()
- setOverrideBlockPlacementRestrictions(Ref, boolean, ComponentAccessor)
- isNoClip()
- setNoClip(Ref, boolean, boolean, ComponentAccessor)
- isFlying(Ref, ComponentAccessor)
- setFlying(Ref, boolean, ComponentAccessor)
- addLocationChange(Ref, double, double, double, ComponentAccessor)
- configTriggerBlockProcessing(boolean, boolean, CollisionResultComponent)
- resetVelocity(Velocity)
- processVelocitySample(double, Vector3d, Velocity)
- getRespawnPosition(Ref, String, ComponentAccessor)
- hasSpawnProtection()
- isWaitingForClientReady()
- isHiddenFromLivingEntity(Ref, Ref, ComponentAccessor)
- setClientViewRadius(int)
- getClientViewRadius()
- getViewRadius()
- toMetricResults()
- setLastSpawnTimeNanos(long)
- getSinceLastSpawnNanos()
- getPlayerRef()
- getMountEntityId()
- setMountEntityId(int)
- getGameMode()
- setGameMode(Ref, GameMode, ComponentAccessor)
- initGameMode(Ref, ComponentAccessor)
- giveItem(ItemStack, Ref, ComponentAccessor)
- hashCode()
- equals(Object)
- toString()
Class Player
java.lang.Object
com.hypixel.hytale.server.core.entity.Entity
com.hypixel.hytale.server.core.entity.LivingEntity
com.hypixel.hytale.server.core.entity.entities.Player
- All Implemented Interfaces:
Component<EntityStore>, MetricProvider, Cloneable
-
Nested Class Summary
Nested classes/interfaces inherited from class Entity
Entity.DefaultAnimations -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BuilderCodec<Player> The codec used to parsePlayerinstancesstatic final intThe default view radius, in chunks, for a playerbooleanDetermines whether to execute block damage for this player, upon collision with damaging blocks.booleanDetermines whether to execute block triggers for this player, upon collision with trigger blocks.static final longThe maximum time, in milliseconds, in which a player is invulnerable after teleportingstatic final MetricsRegistry<Player> The metrics affiliated with playersstatic final KeyedCodec<PlayerConfigData> The keyed codec forPlayerConfigDatainstancesstatic final longThe amount of time, in nanoseconds, in which a player is invulnerable after re-spawningFields inherited from class LivingEntity
DEFAULT_ITEM_THROW_SPEEDFields inherited from class Entity
DISPLAY_NAME, LOGGER, UNASSIGNED_ID, UUID, VERSIONFields inherited from interface Component
EMPTY_ARRAY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddLocationChange(Ref<EntityStore> ref, double deltaX, double deltaY, double deltaZ, ComponentAccessor<EntityStore> componentAccessor) static voidapplyMovementStates(Ref<EntityStore> ref, SavedMovementStates savedMovementStates, MovementStates movementStates, ComponentAccessor<EntityStore> componentAccessor) voidconfigTriggerBlockProcessing(boolean triggers, boolean blockDamage, CollisionResultComponent collisionResultComponent) Called to configure how trigger blocks are processed for this player.voidCalled to copy the parameters and managers to this player from the old player instance.booleanintstatic ComponentType<EntityStore, Player> intDeprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.This field only exists to simplify migrating this class away from it.static CompletableFuture<Transform> getRespawnPosition(Ref<EntityStore> ref, String worldName, ComponentAccessor<EntityStore> componentAccessor) Called to return the respawn position for the given playerlongintstatic ItemStackTransactiongiveItem(ItemStack stack, Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor) voidhandleClientReady(boolean forced) inthashCode()booleanvoidCalled to initialize this player instance with the given parametersstatic voidinitGameMode(Ref<EntityStore> playerRef, ComponentAccessor<EntityStore> componentAccessor) Called during the initialization stage of the players creation to initialize their game-mode and permissions.booleanbooleanisFlying(Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor) Determines whether this player is currently flying.booleanisHiddenFromLivingEntity(Ref<EntityStore> ref, Ref<EntityStore> targetRef, ComponentAccessor<EntityStore> componentAccessor) Determines whether this entity is hidden from the given target entitybooleanisNoClip()Determines whether no-clip is enabled for this player.booleanDetermines whether block placement restrictions are overridden for this player.booleanvoidMarks the chunk containing this entity as needing to be saved.voidmoveTo(Ref<EntityStore> ref, double locX, double locY, double locZ, ComponentAccessor<EntityStore> componentAccessor) static voidnotifyPickupItem(Ref<EntityStore> ref, ItemStack itemStack, org.joml.Vector3d position, ComponentAccessor<EntityStore> componentAccessor) Called to notify the player of an item pick-up, playing expected audio and effectsvoidprocessVelocitySample(double dt, org.joml.Vector3d displacement, Velocity velocity) Updates velocity from the player's movement.booleanremove()Called to remove this entity from the world.voidresetManagers(Holder<EntityStore> holder) Called to reset all the managers affiliated with this playervoidresetVelocity(Velocity velocity) saveConfig(World world, Holder<EntityStore> holder, boolean required) voidsetClientViewRadius(int clientViewRadius) Called to set the current client view radius of this playervoidsetFirstSpawn(boolean firstSpawn) Called to set whether this is the first spawn of the player.voidsetFlying(Ref<EntityStore> ref, boolean flying, ComponentAccessor<EntityStore> componentAccessor) Forces this player into (or out of) the flying state and pushes the change to the client.static voidsetGameMode(Ref<EntityStore> playerRef, GameMode gameMode, ComponentAccessor<EntityStore> componentAccessor) Sets the current game-mode of the given entity.voidsetLastSpawnTimeNanos(long lastSpawnTimeNanos) Called to set the last spawn time of this playervoidsetMountEntityId(int mountEntityId) Called to set the entity ID of the mount entity.voidsetNetworkId(int id) Called to set the network ID for this playervoidsetNoClip(Ref<EntityStore> ref, boolean noClip, boolean notify, ComponentAccessor<EntityStore> componentAccessor) Sets whether no-clip (collision disabled in every movement state) is enabled for this player.voidsetOverrideBlockPlacementRestrictions(Ref<EntityStore> ref, boolean overrideBlockPlacementRestrictions, ComponentAccessor<EntityStore> componentAccessor) Called to set whether block placement restrictions are overridden for this player.voidtoString()Methods inherited from class LivingEntity
getCurrentFallDistance, getInventory, getPackedMaterialAndFluidAtBreathingHeight, setCurrentFallDistance, updateItemStackDurabilityMethods inherited from class Entity
clearReference, clone, getLegacyDisplayName, getNetworkId, getReference, getUuid, getWorld, isCollidable, loadIntoWorld, setLegacyUUID, setReference, toHolder, unloadFromWorld, wasRemovedMethods inherited from interface Component
cloneSerializable
-
Field Details
-
METRICS_REGISTRY
The metrics affiliated with players -
PLAYER_CONFIG_DATA
The keyed codec forPlayerConfigDatainstances -
CODEC
The codec used to parsePlayerinstances -
DEFAULT_VIEW_RADIUS_CHUNKS
public static final int DEFAULT_VIEW_RADIUS_CHUNKSThe default view radius, in chunks, for a player- See Also:
-
RESPAWN_INVULNERABILITY_TIME_NANOS
public static final long RESPAWN_INVULNERABILITY_TIME_NANOSThe amount of time, in nanoseconds, in which a player is invulnerable after re-spawning -
MAX_TELEPORT_INVULNERABILITY_MILLIS
public static final long MAX_TELEPORT_INVULNERABILITY_MILLISThe maximum time, in milliseconds, in which a player is invulnerable after teleporting- See Also:
-
executeTriggers
public boolean executeTriggersDetermines whether to execute block triggers for this player, upon collision with trigger blocks. -
executeBlockDamage
public boolean executeBlockDamageDetermines whether to execute block damage for this player, upon collision with damaging blocks.
-
-
Constructor Details
-
Player
public Player()Default Constructor for aPlayerinstance
-
-
Method Details
-
getComponentType
- Returns:
- the component type for
Playercomponents
-
copyFrom
-
init
-
setNetworkId
public void setNetworkId(int id) Called to set the network ID for this player- Parameters:
id- The specific network ID to set
-
remove
-
moveTo
public void moveTo(@Nonnull Ref<EntityStore> ref, double locX, double locY, double locZ, @Nonnull ComponentAccessor<EntityStore> componentAccessor) - Overrides:
moveToin classLivingEntity- Parameters:
ref- The entity reference of this entity.locX- The X coordinate to move to.locY- The Y coordinate to move to.locZ- The Z coordinate to move to.componentAccessor- TheComponentAccessor<EntityStore>for component access.
-
getPlayerConfigData
- Returns:
- the player configuration data associated with this player
-
markNeedsSave
public void markNeedsSave()Description copied from class:EntityMarks the chunk containing this entity as needing to be saved.- Overrides:
markNeedsSavein classEntity
-
applyMovementStates
public static void applyMovementStates(@Nonnull Ref<EntityStore> ref, @Nonnull SavedMovementStates savedMovementStates, @Nonnull MovementStates movementStates, @Nonnull ComponentAccessor<EntityStore> componentAccessor) -
startClientReadyTimeout
public void startClientReadyTimeout() -
handleClientReady
public void handleClientReady(boolean forced) -
saveConfig
@Nonnull public CompletableFuture<Void> saveConfig(@Nonnull World world, @Nonnull Holder<EntityStore> holder, boolean required) -
getPlayerConnection
Deprecated, for removal: This API element is subject to removal in a future version.Use thePlayerRefto fetch this.This exists only to ease migration- Returns:
- the affiliated
PacketHandlerinstance.
-
getWorldMapTracker
- Returns:
- the affiliated
WorldMapTrackerinstance
-
getWindowManager
- Returns:
- the affiliated
WindowManagerinstance
-
getPageManager
- Returns:
- the affiliated
PageManagerinstance
-
getHudManager
- Returns:
- the affiliated
HudManagerinstance
-
getHotbarManager
- Returns:
- the affiliated
HotbarManagerinstance
-
isFirstSpawn
public boolean isFirstSpawn()- Returns:
trueif this is the first spawn of the player,falseotherwise.
-
setFirstSpawn
public void setFirstSpawn(boolean firstSpawn) Called to set whether this is the first spawn of the player.- Parameters:
firstSpawn- The value to set.
-
resetManagers
Called to reset all the managers affiliated with this player- Parameters:
holder- The holder instance of the player
-
notifyPickupItem
public static void notifyPickupItem(@Nonnull Ref<EntityStore> ref, @Nonnull ItemStack itemStack, @Nullable org.joml.Vector3d position, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Called to notify the player of an item pick-up, playing expected audio and effects- Parameters:
ref- The entity reference of the player entityitemStack- The item stack that has been picked upposition- The position, if applicablecomponentAccessor- TheComponentAccessorfor component access
-
isOverrideBlockPlacementRestrictions
public boolean isOverrideBlockPlacementRestrictions()Determines whether block placement restrictions are overridden for this player.- Returns:
trueif block placement restrictions are overridden,falseotherwise.
-
setOverrideBlockPlacementRestrictions
public void setOverrideBlockPlacementRestrictions(@Nonnull Ref<EntityStore> ref, boolean overrideBlockPlacementRestrictions, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Called to set whether block placement restrictions are overridden for this player.- Parameters:
ref- The entity reference of the player entity.overrideBlockPlacementRestrictions- The value to set.componentAccessor- TheComponentAccessorfor component access.
-
isNoClip
public boolean isNoClip()Determines whether no-clip is enabled for this player.- Returns:
trueif collision is disabled for this player,falseotherwise.
-
setNoClip
public void setNoClip(@Nonnull Ref<EntityStore> ref, boolean noClip, boolean notify, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Sets whether no-clip (collision disabled in every movement state) is enabled for this player.The value is per-session and is not persisted across reconnects.
- Parameters:
ref- The entity reference of the player entity.noClip- The value to set.notify- Whether the client should surface a HUD message for this change.componentAccessor- TheComponentAccessorfor component access.
-
isFlying
public boolean isFlying(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Determines whether this player is currently flying.- Parameters:
ref- The entity reference of the player entity.componentAccessor- TheComponentAccessorfor component access.- Returns:
trueif the player is flying,falseotherwise.
-
setFlying
public void setFlying(@Nonnull Ref<EntityStore> ref, boolean flying, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Forces this player into (or out of) the flying state and pushes the change to the client.This controls the flying state (
MovementStates.flying), not the fly capability. Enabling also grants theMovementSettings.Flycapability (and disabling restores the game-mode default), because the client leaves the flying state as soon as it is not allowed to fly; that capability handling is an internal detail of keeping the state applied.- Parameters:
ref- The entity reference of the player entity.flying- The value to set.componentAccessor- TheComponentAccessorfor component access.
-
addLocationChange
public static void addLocationChange(@Nonnull Ref<EntityStore> ref, double deltaX, double deltaY, double deltaZ, @Nonnull ComponentAccessor<EntityStore> componentAccessor) -
configTriggerBlockProcessing
public void configTriggerBlockProcessing(boolean triggers, boolean blockDamage, @Nonnull CollisionResultComponent collisionResultComponent) Called to configure how trigger blocks are processed for this player.- Parameters:
triggers- Whether to execute trigger blocks.blockDamage- Whether to execute block damage.collisionResultComponent- TheCollisionResultComponentcomponent of the player entity.
-
resetVelocity
-
processVelocitySample
public void processVelocitySample(double dt, @Nonnull org.joml.Vector3d displacement, @Nonnull Velocity velocity) Updates velocity from the player's movement.- Parameters:
dt- The elapsed seconds since the previous sample.displacement- The movement since the previous sample, not an absolute position.velocity- The velocity component to update.
-
getRespawnPosition
@Nonnull public static CompletableFuture<Transform> getRespawnPosition(@Nonnull Ref<EntityStore> ref, @Nonnull String worldName, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Called to return the respawn position for the given player- Parameters:
ref- The entity reference of the player entityworldName- The associated world name that we are fetching the respawn position incomponentAccessor- TheComponentAccessorinstance for component access- Returns:
- the respawn position as a
Transforminstance
-
hasSpawnProtection
public boolean hasSpawnProtection() -
isWaitingForClientReady
public boolean isWaitingForClientReady()- Returns:
trueif we are waiting for the client to be ready,falseotherwise
-
isHiddenFromLivingEntity
public boolean isHiddenFromLivingEntity(@Nonnull Ref<EntityStore> ref, @Nonnull Ref<EntityStore> targetRef, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Description copied from class:EntityDetermines whether this entity is hidden from the given target entity- Overrides:
isHiddenFromLivingEntityin classEntity- Parameters:
ref- The entity reference of this entitytargetRef- The entity reference of the target entitycomponentAccessor- TheComponentAccessorfor component access- Returns:
trueif they are hidden from the target entity,falseotherwise
-
setClientViewRadius
public void setClientViewRadius(int clientViewRadius) Called to set the current client view radius of this player- Parameters:
clientViewRadius- The client view radius to set
-
getClientViewRadius
public int getClientViewRadius()- Returns:
- the current client view radius of the player
-
getViewRadius
public int getViewRadius()- Returns:
- the client view radius in chunks, clamped to
[0, server max].
-
toMetricResults
- Specified by:
toMetricResultsin interfaceMetricProvider
-
setLastSpawnTimeNanos
public void setLastSpawnTimeNanos(long lastSpawnTimeNanos) Called to set the last spawn time of this player- Parameters:
lastSpawnTimeNanos- The given last spawn time to set
-
getSinceLastSpawnNanos
public long getSinceLastSpawnNanos()- Returns:
- the time since the last spawn of this player, in nanoseconds.
-
getPlayerRef
Deprecated, for removal: This API element is subject to removal in a future version.This field only exists to simplify migrating this class away from it. Any new uses should fetch the PlayerRef component manually.- Returns:
- the affiliated
PlayerRefinstance.
-
getMountEntityId
public int getMountEntityId()- Returns:
- the entity ID of the mount entity.
-
setMountEntityId
public void setMountEntityId(int mountEntityId) Called to set the entity ID of the mount entity.- Parameters:
mountEntityId- The ID of the mount entity to set.
-
getGameMode
- Returns:
- the current game mode of the player.
-
setGameMode
public static void setGameMode(@Nonnull Ref<EntityStore> playerRef, @Nonnull GameMode gameMode, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Sets the current game-mode of the given entity.- Parameters:
playerRef- The entity reference of the player entity we are setting the game-mode for.gameMode- TheGameModethat we are switching to.componentAccessor- TheComponentAccessorfor component access.
-
initGameMode
public static void initGameMode(@Nonnull Ref<EntityStore> playerRef, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Called during the initialization stage of the players creation to initialize their game-mode and permissions.- Parameters:
playerRef- The entity reference of the player entity.componentAccessor- TheComponentAccessorfor component access.
-
giveItem
@Nonnull public static ItemStackTransaction giveItem(@Nonnull ItemStack stack, @Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor) -
hashCode
-
equals
-
toString
- Overrides:
toStringin classLivingEntity
-
PlayerRefto fetch this.