API reference / @jsprismarine/protocol / ItemData
Class: ItemData
Defined in: protocol/src/structure/ItemData.ts:24
One entry of ItemRegistryPacket: an item name and the id it travels as.
Wire layout, in docs order: Item Name (string), Item Id (int16 little endian, negative for a block's item form), Is Component Based (boolean), Item Version (varint32 ItemVersion) and Item Component Data (a network NBT compound: little endian with varint lengths). https://mojang.github.io/bedrock-protocol-docs/1.26.51/types/item-data/
Extends
Constructors
Constructor
new ItemData(
itemName,itemId,componentBased,version,componentData?):ItemData
Defined in: protocol/src/structure/ItemData.ts:37
Creates an entry.
Parameters
itemName
string
Item Name, such as minecraft:stick.
itemId
number
Item Id, an int16. Negative for a block's item form.
componentBased
boolean
Is Component Based, true when components define the item.
version
Item Version.
componentData?
Buffer<ArrayBufferLike> | NBTTagCompound = ...
Item Component Data as a compound or captured network-NBT bytes. Defaults to an empty compound.
Returns
ItemData
Overrides
Properties
componentBased
componentBased:
boolean
Defined in: protocol/src/structure/ItemData.ts:40
Is Component Based, true when components define the item.
componentData
componentData:
NBTTagCompound
Defined in: protocol/src/structure/ItemData.ts:26
itemId
itemId:
number
Defined in: protocol/src/structure/ItemData.ts:39
Item Id, an int16. Negative for a block's item form.
itemName
itemName:
string
Defined in: protocol/src/structure/ItemData.ts:38
Item Name, such as minecraft:stick.
version
version:
ItemVersion
Defined in: protocol/src/structure/ItemData.ts:41
Item Version.
Methods
deserialize()
deserialize(
stream):void
Defined in: protocol/src/structure/ItemData.ts:61
Reads the five fields in docs order.
Parameters
stream
Returns
void
Overrides
serialize()
serialize(
stream):void
Defined in: protocol/src/structure/ItemData.ts:51
Writes the five fields in docs order.
Parameters
stream
Returns
void
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.