Skip to content

API reference / @jsprismarine/protocol / SerializableVoxelShape

Class: SerializableVoxelShape ​

Defined in: protocol/src/structure/SerializableVoxelShape.ts:40

A VoxelShapes::SerializableVoxelShape: a block collision shape as a grid of solid and empty cells plus the cell boundaries along each axis, in block units from 0 to 1.

Protocol 2193 wire order: 0. Cells: X Size, Y Size and Z Size as one byte each, then Storage as a varuint32 count followed by that many bytes.

  1. X Coordinates: varuint32 count, then one little-endian float per boundary. A grid with X Size cells has X Size + 1 boundaries.
  2. Y Coordinates: the same along Y.
  3. Z Coordinates: the same along Z.

packages/bedrock-data/src/resources/voxel_shapes.json lists the vanilla shapes under shapes with these fields in camel case, so one entry maps onto the constructor parameters as they are. https://mojang.github.io/bedrock-protocol-docs/1.26.51/types/voxel-shapes-serializable-voxel-shape/

Extends ​

Constructors ​

Constructor ​

new SerializableVoxelShape(cells?, xCoordinates?, yCoordinates?, zCoordinates?): SerializableVoxelShape

Defined in: protocol/src/structure/SerializableVoxelShape.ts:49

Creates a shape. The defaults build the docs' empty shape, handle 0 of the vanilla registry, so the static deserialize can construct an instance before reading the stream.

Parameters ​

cells? ​

SerializableCells = ...

Cells, the grid and its solid flags.

xCoordinates? ​

number[] = ...

X Coordinates, the cell boundaries along X.

yCoordinates? ​

number[] = ...

Y Coordinates, the cell boundaries along Y.

zCoordinates? ​

number[] = ...

Z Coordinates, the cell boundaries along Z.

Returns ​

SerializableVoxelShape

Overrides ​

NetworkStructure.constructor

Properties ​

cells ​

cells: SerializableCells

Defined in: protocol/src/structure/SerializableVoxelShape.ts:50

Cells, the grid and its solid flags.


xCoordinates ​

xCoordinates: number[]

Defined in: protocol/src/structure/SerializableVoxelShape.ts:51

X Coordinates, the cell boundaries along X.


yCoordinates ​

yCoordinates: number[]

Defined in: protocol/src/structure/SerializableVoxelShape.ts:52

Y Coordinates, the cell boundaries along Y.


zCoordinates ​

zCoordinates: number[]

Defined in: protocol/src/structure/SerializableVoxelShape.ts:53

Z Coordinates, the cell boundaries along Z.

Methods ​

deserialize() ​

deserialize(stream): void

Defined in: protocol/src/structure/SerializableVoxelShape.ts:88

Reads the cells and the three coordinate lists in wire order.

Parameters ​

stream ​

BinaryStream

Returns ​

void

Overrides ​

NetworkStructure.deserialize


serialize() ​

serialize(stream): void

Defined in: protocol/src/structure/SerializableVoxelShape.ts:75

Writes the cells and the three coordinate lists in wire order.

Parameters ​

stream ​

BinaryStream

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