Skip to content

Latest commit

 

History

History
347 lines (182 loc) · 10.1 KB

File metadata and controls

347 lines (182 loc) · 10.1 KB

Latite Scripting Documentation (Exports)


Exports > world/entity > Entity

Entity

Class

A class representing an in-game entity.

Source: world/entity.d.ts:4

Hierarchy

Constructors

constructor()

new Entity(): Entity

Returns

Entity

Properties

runtimeId

readonly runtimeId: number

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

Source: world/entity.d.ts:8

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

getDimensionName()

getDimensionName(): string

Get the dimension name. for example, "Overworld"

Source: world/entity.d.ts:42

Returns

string

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

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

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

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

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

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

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

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

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

getPreviousPosition()

getPreviousPosition(): Vector3

Get the position the entity was in the last tick.

Source: world/entity.d.ts:30

Returns

Vector3

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

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

getVelocity()

getVelocity(): Vector3

Gets the entity's movement velocity.

Source: world/entity.d.ts:131

Returns

Vector3

isLocalPlayer()

isLocalPlayer(): boolean

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

Source: world/entity.d.ts:57

Returns

boolean

isPlayer()

isPlayer(): boolean

Whether the entity is a player or not.

Source: world/entity.d.ts:52

Returns

boolean

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

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

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

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