Skip to content

Latest commit

 

History

History
505 lines (262 loc) · 14 KB

File metadata and controls

505 lines (262 loc) · 14 KB

Latite Scripting Documentation (Exports)


Exports > world/entity > Player

Player

Class

A class representing an in-game entity.

Source: world/entity.d.ts:143

Hierarchy

Constructors

constructor()

new Player(): Player

Returns

Player

Inherited from

Entity.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

Entity.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

Entity.attack

getDimensionName()

getDimensionName(): string

Get the dimension name. for example, "Overworld"

Source: world/entity.d.ts:42

Returns

string

Inherited from

Entity.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

Entity.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

Entity.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

Entity.getHealth

getHoldingItem()

getHoldingItem(): ItemStack

Gets the item being held.

Source: world/entity.d.ts:157

Returns

ItemStack

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

Entity.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

Entity.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

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

Entity.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

Entity.getMolangVariable

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

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

Entity.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

Entity.getPositionInterpolated

getPreviousPosition()

getPreviousPosition(): Vector3

Get the position the entity was in the last tick.

Source: world/entity.d.ts:30

Returns

Vector3

Inherited from

Entity.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

Entity.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

Entity.getSaturation

getSelectedSlot()

getSelectedSlot(): number

Gets the slot of the item being held.

Source: world/entity.d.ts:162

Returns

number

getVelocity()

getVelocity(): Vector3

Gets the entity's movement velocity.

Source: world/entity.d.ts:131

Returns

Vector3

Inherited from

Entity.getVelocity

getXUID()

getXUID(): string

Gets the player's Xbox User ID.

Source: world/entity.d.ts:152

Returns

string

isLocalPlayer()

isLocalPlayer(): boolean

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

Source: world/entity.d.ts:57

Returns

boolean

Inherited from

Entity.isLocalPlayer

isPlayer()

isPlayer(): boolean

Whether the entity is a player or not.

Source: world/entity.d.ts:52

Returns

boolean

Inherited from

Entity.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

Entity.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

Entity.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

Entity.setMolangVariable

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

Entity.setVelocity