API reference / @jsprismarine/protocol / SubChunkHeightmapData
Class: SubChunkHeightmapData
Defined in: protocol/src/structure/SubChunkHeightmapData.ts:47
The SubChunkHeightmapData carried by every SubChunkPacket entry.
Protocol 2193 layout, in wire order: Height Map Type as one byte, Subchunk Height Map as an optional HeightMap (a presence byte, then the rows only when present), Render Height Map Type as one byte, then Subchunk Render Height Map as another optional HeightMap. Each row of a heightmap is a varuint32 length (always 16) followed by 16 signed bytes; the row prefixes arrived with the Cereal migration at protocol 2168, which also replaced "present when the type is HasData" with the presence bytes.
Writing checks that a present heightmap is 16 rows of 16 and reading checks each row's length, since a wrong size would leave the stream misaligned for everything after it. https://mojang.github.io/bedrock-protocol-docs/1.26.51/types/sub-chunk-heightmap-data/
Extends
Constructors
Constructor
new SubChunkHeightmapData(
heightMapType?,heightMap?,renderHeightMapType?,renderHeightMap?):SubChunkHeightmapData
Defined in: protocol/src/structure/SubChunkHeightmapData.ts:48
Parameters
heightMapType?
HeightMapDataType = HeightMapDataType.NO_DATA
Height Map Type.
heightMap?
Subchunk Height Map, set when heightMapType is HAS_DATA.
renderHeightMapType?
HeightMapDataType = HeightMapDataType.NO_DATA
Render Height Map Type.
renderHeightMap?
Subchunk Render Height Map, set when renderHeightMapType is HAS_DATA.
Returns
SubChunkHeightmapData
Overrides
Properties
heightMap?
optionalheightMap?:HeightMap
Defined in: protocol/src/structure/SubChunkHeightmapData.ts:52
Subchunk Height Map, set when heightMapType is HAS_DATA.
heightMapType
heightMapType:
HeightMapDataType=HeightMapDataType.NO_DATA
Defined in: protocol/src/structure/SubChunkHeightmapData.ts:50
Height Map Type.
renderHeightMap?
optionalrenderHeightMap?:HeightMap
Defined in: protocol/src/structure/SubChunkHeightmapData.ts:56
Subchunk Render Height Map, set when renderHeightMapType is HAS_DATA.
renderHeightMapType
renderHeightMapType:
HeightMapDataType=HeightMapDataType.NO_DATA
Defined in: protocol/src/structure/SubChunkHeightmapData.ts:54
Render Height Map Type.
Methods
deserialize()
deserialize(
stream):void
Defined in: protocol/src/structure/SubChunkHeightmapData.ts:109
Reads the two type bytes and the heightmaps whose presence bytes say they follow.
Parameters
stream
Returns
void
Throws
when a heightmap row does not carry 16 heights.
Overrides
serialize()
serialize(
stream):void
Defined in: protocol/src/structure/SubChunkHeightmapData.ts:98
Writes Height Map Type, the optional Subchunk Height Map, Render Height Map Type, then the optional Subchunk Render Height Map.
Parameters
stream
Returns
void
Throws
when a present heightmap is not 16 rows of 16 heights.
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.