Skip to content

Latest commit

 

History

History
603 lines (312 loc) · 16.9 KB

File metadata and controls

603 lines (312 loc) · 16.9 KB

Latite Scripting Documentation (Exports)


Exports > world/entity > LocalPlayer

LocalPlayer

Class

A class representing an in-game entity.

Source: world/entity.d.ts:187

Hierarchy

Constructors

constructor()

new LocalPlayer(): LocalPlayer

Returns

LocalPlayer

Inherited from

Player.constructor

Properties

runtimeId

readonly runtimeId: number

The runtime ID of the entity. Local player is always 1.

Source: world/entity.d.ts:8

Inherited from

Player.runtimeId

Methods

attack()

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

Throws

Source: world/entity.d.ts:72

Returns

void

Inherited from

Player.attack

getBreakProgress()

getBreakProgress(): number

Get the progress of breaking a block (ranging from 0 to 1)

Source: world/entity.d.ts:191

Returns

number

getDimensionName()

getDimensionName(): string

Get the dimension name. for example, "Overworld"

Source: world/entity.d.ts:42

Returns

string

Inherited from

Player.getDimensionName

getEntityType()

getEntityType(): number

Gets the entity type ID.

https://minecraft.fandom.com/wiki/Bedrock_Edition_data_values#Entity_IDs

Source: world/entity.d.ts:64

Returns

number

Inherited from

Player.getEntityType

getFlag()

getFlag(flag: number): boolean

Gets a status flag's state in the current entity.

Source: world/entity.d.ts:118

Parameters

Parameter Type
flag number

Returns

boolean

Inherited from

Player.getFlag

getHealth()

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

Returns

number

Inherited from

Player.getHealth

getHoldingItem()

getHoldingItem(): ItemStack

Gets the item being held.

Source: world/entity.d.ts:157

Returns

ItemStack

Inherited from

Player.getHoldingItem

getHunger()

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

Returns

number

Inherited from

Player.getHunger

getHurtTime()

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

Returns

number

Inherited from

Player.getHurtTime

getItem()

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

Parameters

Parameter Type Description
slot number The slot number

Returns

null | ItemStack

Inherited from

Player.getItem

getLastBreakProgress()

getLastBreakProgress(): number

Same as getBreakProgress but doesn't reset

Source: world/entity.d.ts:196

Returns

number

getLookingAt()

getLookingAt(): LookingAt

Get the type of whatever the player is looking at.

Source: world/entity.d.ts:201

Returns

LookingAt

getMolangVariable()

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

Parameters

Parameter Type Description
name MolangVariables The variable name. Example: variable.is_sneaking

Returns

MolangVariable

Inherited from

Player.getMolangVariable

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

Parameters

Parameter Type Description
name string The variable name. Example: variable.is_sneaking

Returns

null | MolangVariable

Inherited from

Player.getMolangVariable

getMovementState()

getMovementState(): MovementState

Gets the movement state of the player (i.e. the movement keys held.)

Source: world/entity.d.ts:212

Returns

MovementState

getName()

getName(): string

Get the player's name (same one as the player list in the pause menu.)

Source: world/entity.d.ts:147

Returns

string

Inherited from

Player.getName

getPosition()

getPosition(): Vector3

Get the position. Note that this will fail if you dont have permission to get the position

Throws

Source: world/entity.d.ts:20

Returns

Vector3

Inherited from

Player.getPosition

getPositionInterpolated()

getPositionInterpolated(): Vector3

Get the interpolated position. Use this in the context of rendering based on entity position.

Source: world/entity.d.ts:25

Returns

Vector3

Inherited from

Player.getPositionInterpolated

getPreviousPosition()

getPreviousPosition(): Vector3

Get the position the entity was in the last tick.

Source: world/entity.d.ts:30

Returns

Vector3

Inherited from

Player.getPreviousPosition

getRotation()

getRotation(): Vector2

Get the rotation. Note that this will fail if you dont have permission to get the rotation

Throws

Source: world/entity.d.ts:36

Returns

Vector2

Inherited from

Player.getRotation

getSaturation()

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

Returns

number

Inherited from

Player.getSaturation

getSelectedBlock()

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

Returns

null | Vector3

getSelectedSlot()

getSelectedSlot(): number

Gets the slot of the item being held.

Source: world/entity.d.ts:162

Returns

number

Inherited from

Player.getSelectedSlot

getVelocity()

getVelocity(): Vector3

Gets the entity's movement velocity.

Source: world/entity.d.ts:131

Returns

Vector3

Inherited from

Player.getVelocity

getXUID()

getXUID(): string

Gets the player's Xbox User ID.

Source: world/entity.d.ts:152

Returns

string

Inherited from

Player.getXUID

isLocalPlayer()

isLocalPlayer(): boolean

Whether the entity is the local player (yourself) or not.

Source: world/entity.d.ts:57

Returns

boolean

Inherited from

Player.isLocalPlayer

isPlayer()

isPlayer(): boolean

Whether the entity is a player or not.

Source: world/entity.d.ts:52

Returns

boolean

Inherited from

Player.isPlayer

isValid()

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

Returns

boolean

Inherited from

Player.isValid

setFlag()

setFlag(flag: number, value: boolean): void

Sets a status flag's state in the current entity.

Source: world/entity.d.ts:126

Parameters

Parameter Type Description
flag number -
value boolean The new status flag value.

Returns

void

Inherited from

Player.setFlag

setMolangVariable()

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

Parameters

Parameter Type Description
name string The variable name. Example: variable.is_sneaking
value number The variable's new value.

Returns

null | number

Inherited from

Player.setMolangVariable

setMovementState()

setMovementState(state: MovementState): void

Sets the movement state of the player

Source: world/entity.d.ts:218

Parameters

Parameter Type Description
state MovementState The state to update to

Returns

void

setVelocity()

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

Parameters

Parameter Type Description
vector Vector3 The new velocity

Returns

void

Inherited from

Player.setVelocity