Skip to content

API reference / @jsprismarine/protocol / PrimitiveShapeData

Class: PrimitiveShapeData ​

Defined in: protocol/src/structure/PrimitiveShapeData.ts:175

One debug shape of a PrimitiveShapesPacket: a new shape, an update to one the client already draws, or a removal.

Protocol 2193 wire order: NetworkId as a varuint64, then Shape Type (one byte), Location (Vec3), Scale (float), Rotation (Vec3), Total Time Left (float), Maximum Render Distance (float), Color (little-endian int32 ARGB), Dimension ID (ZigZag varint32) and Attached To Entity ID (ZigZag varint64), each an optional with a presence byte before the value. Last comes Extra Shape Data as a Cereal tagged variant: a varuint32 selector (the PrimitiveShapeExtraDataType value) then the alternative's fields. The arrow's four fields, the text's BackgroundColor and the pyramid's Depth are optionals too; every other alternative field is written bare.

The 1.26.51 schema lists Dimension ID and the arrow fields as required and only marks them optional at protocol 2207. gophertunnel and Cloudburst have written the presence byte for them at every protocol since the packet appeared, including their 2193 codecs, so this class does the same. https://mojang.github.io/bedrock-protocol-docs/1.26.51/types/primitive-shape-data-payload/

Extends ​

Implements ​

Constructors ​

Constructor ​

new PrimitiveShapeData(fields?): PrimitiveShapeData

Defined in: protocol/src/structure/PrimitiveShapeData.ts:192

Creates a shape entry. The default is a removal of shape 0: no type, no extra data.

Parameters ​

fields? ​

PrimitiveShapeDataFields = ...

The shape's fields; absent optionals are not written.

Returns ​

PrimitiveShapeData

Overrides ​

NetworkStructure.constructor

Properties ​

attachedToEntityId? ​

optional attachedToEntityId?: bigint

Defined in: protocol/src/structure/PrimitiveShapeData.ts:185

Attached To Entity ID, the ActorUniqueID of the entity the shape follows.

Implementation of ​

PrimitiveShapeDataFields.attachedToEntityId


color? ​

optional color?: number

Defined in: protocol/src/structure/PrimitiveShapeData.ts:183

Color as ARGB packed 0xAARRGGBB in an unsigned 32-bit integer.

Implementation of ​

PrimitiveShapeDataFields.color


dimensionId? ​

optional dimensionId?: Dimension

Defined in: protocol/src/structure/PrimitiveShapeData.ts:184

Dimension ID the shape renders in.

Implementation of ​

PrimitiveShapeDataFields.dimensionId


extraData ​

extraData: PrimitiveShapeExtraData

Defined in: protocol/src/structure/PrimitiveShapeData.ts:186

Extra Shape Data for the shape's type.

Implementation of ​

PrimitiveShapeDataFields.extraData


location? ​

optional location?: Vec3

Defined in: protocol/src/structure/PrimitiveShapeData.ts:178

Location in the world.

Implementation of ​

PrimitiveShapeDataFields.location


maxRenderDistance? ​

optional maxRenderDistance?: number

Defined in: protocol/src/structure/PrimitiveShapeData.ts:182

Maximum Render Distance from the camera.

Implementation of ​

PrimitiveShapeDataFields.maxRenderDistance


networkId ​

networkId: bigint

Defined in: protocol/src/structure/PrimitiveShapeData.ts:176

NetworkId that pairs the shape on the server with the one on the client.

Implementation of ​

PrimitiveShapeDataFields.networkId


rotation? ​

optional rotation?: Vec3

Defined in: protocol/src/structure/PrimitiveShapeData.ts:180

Rotation as Euler angles in radians, pitch then yaw then roll.

Implementation of ​

PrimitiveShapeDataFields.rotation


scale? ​

optional scale?: number

Defined in: protocol/src/structure/PrimitiveShapeData.ts:179

Scale.

Implementation of ​

PrimitiveShapeDataFields.scale


shapeType? ​

optional shapeType?: PrimitiveShapeType

Defined in: protocol/src/structure/PrimitiveShapeData.ts:177

Shape Type. A shape sent without one is removed on the client.

Implementation of ​

PrimitiveShapeDataFields.shapeType


totalTimeLeft? ​

optional totalTimeLeft?: number

Defined in: protocol/src/structure/PrimitiveShapeData.ts:181

Total Time Left in seconds until the client removes the shape; 0 keeps it.

Implementation of ​

PrimitiveShapeDataFields.totalTimeLeft

Methods ​

deserialize() ​

deserialize(stream): void

Defined in: protocol/src/structure/PrimitiveShapeData.ts:357

Reads a shape entry.

Parameters ​

stream ​

NetworkBinaryStream

Returns ​

void

Throws ​

when the Extra Shape Data selector names none of the ten alternatives.

Overrides ​

NetworkStructure.deserialize


serialize() ​

serialize(stream): void

Defined in: protocol/src/structure/PrimitiveShapeData.ts:339

Writes a shape entry: Network ID, then each optional field behind its presence byte, then the Extra Shape Data variant.

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