Skip to content

API reference / @jsprismarine/protocol / Vec3

Class: Vec3 ​

Defined in: protocol/src/structure/Vec3.ts:8

Represents the network structure of a 3D vector. https://mojang.github.io/bedrock-protocol-docs/1.26.51/types/vec3/

Extends ​

Extended by ​

Constructors ​

Constructor ​

new Vec3(x, y, z): Vec3

Defined in: protocol/src/structure/Vec3.ts:15

Creates a new instance of Vec3.

Parameters ​

x ​

number

The x-coordinate of the vector.

y ​

number

The y-coordinate of the vector.

z ​

number

The z-coordinate of the vector.

Returns ​

Vec3

Overrides ​

Vec2.constructor

Properties ​

x ​

x: number

Defined in: protocol/src/structure/Vec2.ts:15

The x-coordinate of the vector.

Inherited from ​

Vec2.x


y ​

y: number

Defined in: protocol/src/structure/Vec2.ts:16

The y-coordinate of the vector.

Inherited from ​

Vec2.y


z ​

z: number

Defined in: protocol/src/structure/Vec3.ts:18

The z-coordinate of the vector.

Methods ​

deserialize() ​

deserialize(stream): void

Defined in: protocol/src/structure/Vec3.ts:37

Deserializes the vector from a binary stream.

Parameters ​

stream ​

BinaryStream

The binary stream to read from.

Returns ​

void

Overrides ​

Vec2.deserialize


serialize() ​

serialize(stream): void

Defined in: protocol/src/structure/Vec3.ts:27

Serializes the vector into a binary stream.

Parameters ​

stream ​

BinaryStream

The binary stream to write to.

Returns ​

void

Overrides ​

Vec2.serialize


deserialize() ​

static deserialize<T>(this, stream): T

Defined in: protocol/src/NetworkStructure.ts:28

Deserializes the network structure from a binary stream. The constructor runs with no arguments before the stream is read, so the class must tolerate that.

Type Parameters ​

T ​

T extends NetworkStructure

Parameters ​

this ​

Constructor<T>

stream ​

NetworkBinaryStream

The binary stream to deserialize from.

Returns ​

T

An instance of the class T.

Inherited from ​

Vec2.deserialize