API reference / @jsprismarine/protocol / Vec2
Class: Vec2
Defined in: protocol/src/structure/Vec2.ts:8
Represents the network structure of a 2D vector. https://mojang.github.io/bedrock-protocol-docs/1.26.51/types/vec2/
Extends
Extended by
Constructors
Constructor
new Vec2(
x,y):Vec2
Defined in: protocol/src/structure/Vec2.ts:14
Creates a new instance of Vec2.
Parameters
x
number
The x-coordinate of the vector.
y
number
The y-coordinate of the vector.
Returns
Vec2
Overrides
Properties
x
x:
number
Defined in: protocol/src/structure/Vec2.ts:15
The x-coordinate of the vector.
y
y:
number
Defined in: protocol/src/structure/Vec2.ts:16
The y-coordinate of the vector.
Methods
deserialize()
deserialize(
stream):void
Defined in: protocol/src/structure/Vec2.ts:34
Deserializes the vector from a binary stream.
Parameters
stream
The binary stream to deserialize from.
Returns
void
Overrides
serialize()
serialize(
stream):void
Defined in: protocol/src/structure/Vec2.ts:25
Serializes the vector into a binary stream.
Parameters
stream
The binary stream to serialize into.
Returns
void
Overrides
deserialize()
staticdeserialize<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
The binary stream to deserialize from.
Returns
T
An instance of the class T.