Latite Scripting Documentation (Exports)
Exports > world/entity > LocalPlayer
Class
A class representing an in-game entity.
Source: world/entity.d.ts:187
Player.LocalPlayer
new LocalPlayer():
LocalPlayer
readonlyruntimeId:number
The runtime ID of the entity. Local player is always 1.
Source: world/entity.d.ts:8
attack():
void
Makes your player attack the entity. Only works if you have operator
This function is restricted - meaning it will only work on LocalPlayer or if you have OP
Source: world/entity.d.ts:72
void
getBreakProgress():
number
Get the progress of breaking a block (ranging from 0 to 1)
Source: world/entity.d.ts:191
number
getDimensionName():
string
Get the dimension name. for example, "Overworld"
Source: world/entity.d.ts:42
string
getEntityType():
number
Gets the entity type ID.
https://minecraft.fandom.com/wiki/Bedrock_Edition_data_values#Entity_IDs
Source: world/entity.d.ts:64
number
getFlag(flag:
number):boolean
Gets a status flag's state in the current entity.
Source: world/entity.d.ts:118
| Parameter | Type |
|---|---|
| flag | number |
boolean
getHealth():
number
Gets the health of the entity.
This function is restricted - meaning it will only work on LocalPlayer or if you have OP
Source: world/entity.d.ts:79
number
getHoldingItem():
ItemStack
Gets the item being held.
Source: world/entity.d.ts:157
getHunger():
number
Gets the hunger of the entity.
This function is restricted - meaning it will only work on LocalPlayer or if you have OP
Source: world/entity.d.ts:86
number
getHurtTime():
number
Gets the number of ticks that the entity is invulnerable (after the entity is hit/hurt), ranges from 0-10
Source: world/entity.d.ts:47
number
getItem(slot:
number):null|ItemStack
Gets the item at the current inventory slot. Will return null if the specified slot is out of bounds
Source: world/entity.d.ts:168
| Parameter | Type | Description |
|---|---|---|
| slot | number |
The slot number |
null | ItemStack
getLastBreakProgress():
number
Same as getBreakProgress but doesn't reset
Source: world/entity.d.ts:196
number
getLookingAt():
LookingAt
Get the type of whatever the player is looking at.
Source: world/entity.d.ts:201
getMolangVariable(name:
MolangVariables):MolangVariable
Gets the value of a MoLang variable. Returns null if the variable was not found.
Source: world/entity.d.ts:99
| Parameter | Type | Description |
|---|---|---|
| name | MolangVariables |
The variable name. Example: variable.is_sneaking |
getMolangVariable(name:
string):null|MolangVariable
Gets the value of a MoLang variable. Returns null if the variable was not found.
Source: world/entity.d.ts:105
| Parameter | Type | Description |
|---|---|---|
| name | string |
The variable name. Example: variable.is_sneaking |
null | MolangVariable
getMovementState():
MovementState
Gets the movement state of the player (i.e. the movement keys held.)
Source: world/entity.d.ts:212
getName():
string
Get the player's name (same one as the player list in the pause menu.)
Source: world/entity.d.ts:147
string
getPosition():
Vector3
Get the position. Note that this will fail if you dont have permission to get the position
Source: world/entity.d.ts:20
getPositionInterpolated():
Vector3
Get the interpolated position. Use this in the context of rendering based on entity position.
Source: world/entity.d.ts:25
Player.getPositionInterpolated
getPreviousPosition():
Vector3
Get the position the entity was in the last tick.
Source: world/entity.d.ts:30
getRotation():
Vector2
Get the rotation. Note that this will fail if you dont have permission to get the rotation
Source: world/entity.d.ts:36
getSaturation():
number
Gets the saturation of the entity.
This function is restricted - meaning it will only work on LocalPlayer or if you have OP
Source: world/entity.d.ts:93
number
getSelectedBlock():
null|Vector3
Get the block selected by looking at it. Will return null if no block is selected.
Source: world/entity.d.ts:206
null | Vector3
getSelectedSlot():
number
Gets the slot of the item being held.
Source: world/entity.d.ts:162
number
getVelocity():
Vector3
Gets the entity's movement velocity.
Source: world/entity.d.ts:131
getXUID():
string
Gets the player's Xbox User ID.
Source: world/entity.d.ts:152
string
isLocalPlayer():
boolean
Whether the entity is the local player (yourself) or not.
Source: world/entity.d.ts:57
boolean
isPlayer():
boolean
Whether the entity is a player or not.
Source: world/entity.d.ts:52
boolean
isValid():
boolean
Check if the entity is still valid. In some cases, Latite may invalidate an entity outside of an event listener. This is to prevent the scripting engine from being used as a cheat.
Source: world/entity.d.ts:14
boolean
setFlag(flag:
number, value:boolean):void
Sets a status flag's state in the current entity.
Source: world/entity.d.ts:126
| Parameter | Type | Description |
|---|---|---|
| flag | number |
- |
| value | boolean |
The new status flag value. |
void
setMolangVariable(name:
string, value:number):null|number
[Experimental] sets a MoLang variable's value. Returns null if unsuccessful and the number that was set if it was successful.
Source: world/entity.d.ts:112
| Parameter | Type | Description |
|---|---|---|
| name | string |
The variable name. Example: variable.is_sneaking |
| value | number |
The variable's new value. |
null | number
setMovementState(state:
MovementState):void
Sets the movement state of the player
Source: world/entity.d.ts:218
| Parameter | Type | Description |
|---|---|---|
| state | MovementState |
The state to update to |
void
setVelocity(vector:
Vector3):void
Sets the entity's movement velocity.
This function is restricted - it only works if you have operator.
Source: world/entity.d.ts:140
| Parameter | Type | Description |
|---|---|---|
| vector | Vector3 |
The new velocity |
void