Skip to content

API reference / @jsprismarine/protocol / SubChunkPos

Class: SubChunkPos ​

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

An absolute sub chunk position, counted in sub chunks: Subchunk Position X, Subchunk Position Y, then Subchunk Position Z, each a little-endian int32.

SubChunkPacket and SubChunkRequestPacket use it as the center every offset is relative to. Unlike BlockPos and ChunkPos, the coordinates are not varints; the schema carries no Compression flag and the Cereal migration at protocol 2168 moved them from ZigZag varint32 to fixed int32. https://mojang.github.io/bedrock-protocol-docs/1.26.51/types/sub-chunk-pos/

Extends ​

Constructors ​

Constructor ​

new SubChunkPos(x?, y?, z?): SubChunkPos

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

Parameters ​

x? ​

number = 0

y? ​

number = 0

z? ​

number = 0

Returns ​

SubChunkPos

Overrides ​

NetworkStructure.constructor

Properties ​

x ​

x: number = 0

Defined in: protocol/src/structure/SubChunkPos.ts:17


y ​

y: number = 0

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


z ​

z: number = 0

Defined in: protocol/src/structure/SubChunkPos.ts:19

Methods ​

deserialize() ​

deserialize(stream): void

Defined in: protocol/src/structure/SubChunkPos.ts:32

Reads X, Y, then Z, each a little-endian int32.

Parameters ​

stream ​

NetworkBinaryStream

Returns ​

void

Overrides ​

NetworkStructure.deserialize


serialize() ​

serialize(stream): void

Defined in: protocol/src/structure/SubChunkPos.ts:25

Writes X, Y, then Z, each a little-endian int32.

Parameters ​

stream ​

NetworkBinaryStream

Returns ​

void

Overrides ​

NetworkStructure.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 ​

NetworkStructure.deserialize