Player
The player API inherits functions from the living entity API
The player API is accessed through the player
global. Like so: player:isGliding()
This page is a WIP. It contains all the information in Figura's documentation but we're working on adding more helpful descriptions.
Player information that isn't synced between clients is kept in the host API. Examples of unsynced data are: Creative flying, status effects, and remaining air amount.
There are times during a script's functioning where the script will run, but the player global will be empty. This will cause the "Tried to access the EntityAPI before its initialization" error. To solve this, move the player API call into a protected event, like tick
. If you wish to initialize a check during the initialization phase of a script (outside of any other event) you can use the entity_init
event.
All provided examples assume you're using a tick event.
To reiterate:
player:isGliding() -- will error
function events.entity_init()
player:isGliding() -- will not error, but will only play once
end
player:isGliding() -- will error
function events.tick()
player:isGliding() -- won't error, and will update once a tick
end
player:isGliding() -- will error
Player Transformations
getPos()
Gets the position of the entity in the world
If delta is passed in, then it will be used to linearly interpolate the position of the entity between the previous tick and the current tick
The default value of delta is 1
- Overload 1
- Overload 2
Example:
player:getPos()
getRot()
Gets the rotation of the entity in degrees
If delta is passed in, then it will be used to linearly interpolate the rotation of the entity between the previous tick and the current tick
The default value of delta is 1
- Overload 1
- Overload 2
Example:
player:getRot()
getBodyYaw()
Gets the yaw of this entity's body in degrees
If delta is passed in, then it will be used to linearly interpolate the rotation of the body between the previous tick and the current tick
The default value of delta is 1
- Overload 1
- Overload 2
Example:
player:getBodyYaw()
getLookDir()
Returns a unit vector pointing in the direction that this entity is looking
See the blue line in the F3+B screen for an example
getLookDir()
Returns:
Type | Description |
---|---|
Vector3 | - |
Example:
player:getLookDir()
getVelocity()
Gets the current velocity of this entity in world coordinates, calculated as its position this tick minus its position last tick
getVelocity()
Returns:
Type | Description |
---|---|
Vector3 | - |
Example:
player:getVelocity()
Player Actions
getPose()
Returns the current pose of the player
This can be one of: "STANDING", "FALL_FLYING", "SLEEPING", "SWIMMING", "SPIN_ATTACK", "CROUCHING", "LONG_JUMPING", or "DYING"
getPose()
Returns:
Type | Description |
---|---|
String | - |
Example:
player:getPose() == "CROUCHING"
isCrouching()
Returns true if this entity is visually sneaking
isCrouching()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
player:isCrouching()
isGliding()
Returns if this entity is gliding with an elytra
isGliding()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
player:isGliding() -- will error
function events.entity_init()
player:isGliding() -- will not error, but will only play once
end
player:isGliding() -- will error
function events.tick()
player:isGliding() -- won't error, and will update once a tick
end
player:isGliding() -- will error
isFishing()
Returns if the player is currently fishing
isFishing()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
player:isFishing()
isBlocking()
Return if this entity is blocking with a shield
isBlocking()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
player:isBlocking()
isVisuallySwimming()
Returns if this entity has the swimming pose
isVisuallySwimming()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
player:isVisuallySwimming()
isClimbing()
Returns true if the entity is currently using a climbable block, like a ladder or vine
isClimbing()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
player:isClimbing()
isSneaking()
Returns true if this entity is logically sneaking (can't fall from blocks edges, can't see nameplate behind walls, etc)
isSneaking()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
player:isSneaking()
isSprinting()
Returns true if this entity is currently sprinting
isSprinting()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
player:isSprinting()
riptideSpinning()
Returns if this entity is riptide spinning
riptideSpinning()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
player:riptideSpinning()