Skip to content

API reference / @jsprismarine/protocol / NetworkItemStackDescriptor

Class: NetworkItemStackDescriptor ​

Defined in: protocol/src/structure/NetworkItemStackDescriptor.ts:21

An item stack as an inventory, an equipped hand or a transaction carries it.

Wire layout, in docs order: Id (int16 little endian, 0 for an empty stack), Stack size (uint16 little endian), Aux value (varuint32), Net Id Variant (optional: a boolean, then a varint32 when true), Block Runtime Id (varuint32) and User Data Buffer (a varuint32 length, then the ItemInstanceUserData bytes). https://mojang.github.io/bedrock-protocol-docs/1.26.51/types/network-item-stack-descriptor/

Extends ​

Constructors ​

Constructor ​

new NetworkItemStackDescriptor(id, stackSize, auxValue, includeNetid, blockRuntimeId, config?): NetworkItemStackDescriptor

Defined in: protocol/src/structure/NetworkItemStackDescriptor.ts:47

Creates a descriptor.

Parameters ​

id ​

number

Id, the item's network id, or 0 for an empty stack.

stackSize ​

number

Stack size.

auxValue ​

number

Aux value, the item's metadata.

includeNetid ​

boolean

Whether Net Id Variant is present.

blockRuntimeId ​

number

Block Runtime Id, or 0 when the item places no block.

config? ​

NetworkItemStackDescriptorConfig = {}

The net id variant and the user data blob.

Returns ​

NetworkItemStackDescriptor

Overrides ​

NetworkStructure.constructor

Properties ​

auxValue ​

auxValue: number

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

Aux value, the item's metadata.


blockRuntimeId ​

blockRuntimeId: number

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

Block Runtime Id, or 0 when the item places no block.


id ​

id: number

Defined in: protocol/src/structure/NetworkItemStackDescriptor.ts:48

Id, the item's network id, or 0 for an empty stack.


includeNetid ​

includeNetid: boolean

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

Whether Net Id Variant is present.


netIdVariant ​

netIdVariant: number

Defined in: protocol/src/structure/NetworkItemStackDescriptor.ts:23

Net Id Variant, meaningful only when includeNetid is true.


stackSize ​

stackSize: number

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

Stack size.


userDataBuffer ​

userDataBuffer: Buffer

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

User Data Buffer, a serialized ItemInstanceUserData.

Methods ​

deserialize() ​

deserialize(stream): void

Defined in: protocol/src/structure/NetworkItemStackDescriptor.ts:80

Reads the descriptor in docs order. The user data blob is kept as bytes, not parsed.

Parameters ​

stream ​

NetworkBinaryStream

Returns ​

void

Overrides ​

NetworkStructure.deserialize


serialize() ​

serialize(stream): void

Defined in: protocol/src/structure/NetworkItemStackDescriptor.ts:61

Writes the descriptor in docs order. An empty stack writes zeroes for every field after the id.

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