[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / [item/Item](https://jsprismarine.dev/api/@jsprismarine/prismarine/item/Item/index.md) / Item

# Class: Item

Defined in: [packages/prismarine/src/item/Item.ts:194](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L194)

One item stack, as the rest of the server holds one.

Everything it answers about itself - how hard it hits, how much armor it
is worth, how much durability it has, what it harvests - is read off Java's
data components rather than declared by a subclass. The 65 item classes
this replaced each restated one or two of those numbers; the table has all
of them, for all 1613 items.

## Constructors

### Constructor

> **new Item**(`__namedParameters`): `Item`

Defined in: [packages/prismarine/src/item/Item.ts:277](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L277)

#### Parameters

##### \_\_namedParameters

[`ItemProps`](https://jsprismarine.dev/api/@jsprismarine/prismarine/item/Item/index.md#itemprops)

#### Returns

`Item`

## Properties

### count

> **count**: `number` = `1`

Defined in: [packages/prismarine/src/item/Item.ts:204](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L204)

***

### durability

> **durability**: `number`

Defined in: [packages/prismarine/src/item/Item.ts:200](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L200)

***

### meta

> **meta**: `number` = `0`

Defined in: [packages/prismarine/src/item/Item.ts:199](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L199)

***

### nbt

> **nbt**: `null` = `null`

Defined in: [packages/prismarine/src/item/Item.ts:203](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L203)

***

### selectedBundleItem

> **selectedBundleItem**: `number` = `-1`

Defined in: [packages/prismarine/src/item/Item.ts:228](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L228)

The place in the stack's `minecraft:bundle_contents` of the stack the player picked in the
bundle's tooltip, or -1 for none; see `bundleContents.ts`.

Changed in place, as vanilla changes its stack, because the client that picked it already
shows it: like vanilla's it is neither saved nor sent, and a slot is not shown again for it.
Every copy keeps it but one with new bundle contents.

#### Java See

BundleContents.selectedItem

***

### stackNetworkId

> **stackNetworkId**: `number` = `0`

Defined in: [packages/prismarine/src/item/Item.ts:217](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L217)

The stack network id the client knows this stack by, or 0 before it has one.

The inventory packets write it, so that a client and the server name a stack by the same
number in an `ItemStackRequest` and in its answer. A stack read off the wire keeps the id
it came with.

Ids are counted per player by `HumanInventory.assignStackNetworkId`. A stack keeps its id
when it moves whole or changes size through [Item.withCount](#withcount); every other copy starts
without one, and so does a part split off a stack.

## Methods

### asPredicateStack()

> **asPredicateStack**(): [`ItemStack`](https://jsprismarine.dev/api/@jsprismarine/predicates/index.md#itemstack)

Defined in: [packages/prismarine/src/item/Item.ts:777](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L777)

This stack as the loot, predicate and enchantment grammars read one.

The components carry what those grammars actually look at today:
`minecraft:enchantments` for Fortune, Looting, Silk Touch and every
effect component, and the three the item type declares that the
enchanting table and the anvil read off a stack -
`minecraft:enchantable`, `minecraft:max_damage` and `minecraft:damage`.
An empty map used to go out here, which made every `apply_bonus` see an
unenchanted tool and every enchanting table refuse every item.

#### Returns

[`ItemStack`](https://jsprismarine.dev/api/@jsprismarine/predicates/index.md#itemstack)

***

### getAmount()

> **getAmount**(): `number`

Defined in: [packages/prismarine/src/item/Item.ts:690](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L690)

#### Returns

`number`

***

### getArmorDefensePoints()

> **getArmorDefensePoints**(): `number`

Defined in: [packages/prismarine/src/item/Item.ts:471](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L471)

The armor points the item is worth while worn.

#### Returns

`number`

***

### getArmorToughness()

> **getArmorToughness**(): `number`

Defined in: [packages/prismarine/src/item/Item.ts:476](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L476)

The armor toughness the item is worth while worn.

#### Returns

`number`

***

### getAttackDamage()

> **getAttackDamage**(): `number`

Defined in: [packages/prismarine/src/item/Item.ts:466](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L466)

Half-hearts a swing with this in hand is worth.

The player's own base of one, plus the item's
`minecraft:base_attack_damage` modifier. A bare fist and a torch are
both worth one, which is vanilla's rule rather than a placeholder.

#### Returns

`number`

***

### getBlockRuntimeId()

> **getBlockRuntimeId**(): `number`

Defined in: [packages/prismarine/src/item/Item.ts:907](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L907)

The runtime id of the block this item places, or zero for anything that places none.

An id given at construction wins. Otherwise the name resolves to the block's default
state, which is right for a stack a player holds and wrong for two kinds of creative
entry: a block the menu shows in another state (a piston faces up there), and the item
form of a block vanilla treats as a plain item (a door, a bed, a hanging sign travel with
a zero) while this server has a block schema under the same name.

#### Returns

`number`

the hashed block runtime id, or `0`.

***

### getBurnTime()

> **getBurnTime**(): `number`

Defined in: [packages/prismarine/src/item/Item.ts:454](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L454)

How long the item burns in a furnace, in ticks.

#### Returns

`number`

***

### getCanDestroyBlocks()

> **getCanDestroyBlocks**(): readonly `string`[]

Defined in: [packages/prismarine/src/item/Item.ts:525](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L525)

The Bedrock block identifiers this stack may destroy.

#### Returns

readonly `string`[]

***

### getCanPlaceOnBlocks()

> **getCanPlaceOnBlocks**(): readonly `string`[]

Defined in: [packages/prismarine/src/item/Item.ts:520](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L520)

The Bedrock block identifiers this stack may be placed on.

#### Returns

readonly `string`[]

***

### getComponents()

> **getComponents**(): `StackComponents`

Defined in: [packages/prismarine/src/item/Item.ts:539](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L539)

The Java components the stack sets beyond its enchantments, name, lore, durability,
contents and map, by namespaced id: what a smithing trim, a dye, a firework recipe or a
trade wrote onto it. Empty for most stacks.

#### Returns

`StackComponents`

***

### getContent()

> **getContent**(): [`ServerContent`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/ServerContent/index.md#servercontent) \| `undefined`

Defined in: [packages/prismarine/src/item/Item.ts:317](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L317)

The content the stack reads its item type from, or undefined for Java's committed table.

#### Returns

[`ServerContent`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/ServerContent/index.md#servercontent) \| `undefined`

***

### getContents()

> **getContents**(): readonly (`Item` \| `null`)[]

Defined in: [packages/prismarine/src/item/Item.ts:515](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L515)

What this stack holds inside it, one entry per slot and null for an empty one.

Empty for everything but a container item, which today is the shulker box.

#### Returns

readonly (`Item` \| `null`)[]

***

### getCustomName()

> **getCustomName**(): `string` \| `undefined`

Defined in: [packages/prismarine/src/item/Item.ts:501](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L501)

The name an anvil gave this stack, or undefined when it still has the item's own.

#### Returns

`string` \| `undefined`

***

### getDurability()

> **getDurability**(): `number`

Defined in: [packages/prismarine/src/item/Item.ts:682](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L682)

#### Returns

`number`

***

### getEnchantmentLevel()

> **getEnchantmentLevel**(`enchantment`): `number`

Defined in: [packages/prismarine/src/item/Item.ts:496](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L496)

The level of one enchantment, or zero when the stack does not carry it.

#### Parameters

##### enchantment

`string`

A namespaced or bare Java enchantment id.

#### Returns

`number`

***

### getEnchantments()

> **getEnchantments**(): `ReadonlyMap`\<`string`, `number`\>

Defined in: [packages/prismarine/src/item/Item.ts:487](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L487)

The stack's enchantments, by namespaced Java id.

Java ids and not Bedrock ones, because the enchantment definitions, the
loot tables and the effect components are all Java's and converting at
every read would mean converting back to run any of them.

#### Returns

`ReadonlyMap`\<`string`, `number`\>

***

### getEquipmentSlot()

> **getEquipmentSlot**(): `string` \| `undefined`

Defined in: [packages/prismarine/src/item/Item.ts:449](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L449)

Where `minecraft:equippable` says this item is worn.

The game's own answer to which slot an item occupies, which is what dressing a mob from a
loot table needs: the table names `minecraft:iron_helmet` and nothing else says it is a
helmet. One of `@jsprismarine/items`' `EQUIPMENT_SLOTS`.

#### Returns

`string` \| `undefined`

The slot name, or undefined for an item that is not worn,
  which a sword and a bow are.

***

### getJavaTags()

> **getJavaTags**(): readonly `string`[]

Defined in: [packages/prismarine/src/item/Item.ts:332](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L332)

The Java datapack tags attached to this Bedrock item type.

#### Returns

readonly `string`[]

***

### getLore()

> **getLore**(): readonly `string`[]

Defined in: [packages/prismarine/src/item/Item.ts:506](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L506)

The lore lines on this stack, which is an empty array for most of them.

#### Returns

readonly `string`[]

***

### getMapId()

> **getMapId**(): `number` \| `undefined`

Defined in: [packages/prismarine/src/item/Item.ts:530](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L530)

Which saved map this stack shows, or undefined for anything but a filled map that has one.

#### Returns

`number` \| `undefined`

***

### getMaxAmount()

> **getMaxAmount**(): `number`

Defined in: [packages/prismarine/src/item/Item.ts:686](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L686)

#### Returns

`number`

***

### getMaxDurability()

> **getMaxDurability**(): `number`

Defined in: [packages/prismarine/src/item/Item.ts:678](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L678)

#### Returns

`number`

***

### getMeta()

> **getMeta**(): `number`

Defined in: [packages/prismarine/src/item/Item.ts:387](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L387)

The stack's damage or variant value, which the wire carries beside the id.

#### Returns

`number`

***

### getMiningSpeed()

> **getMiningSpeed**(`block`): `number`

Defined in: [packages/prismarine/src/item/Item.ts:746](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L746)

How fast this mines one block, which is Java's `Player.getDestroySpeed`
as far as a stack alone can answer it.

The `minecraft:tool` rules give the base - the first rule whose block
set matches and that states a speed - and `minecraft:mining_efficiency`
raises it, which is the attribute Efficiency's modifier writes. Java
only adds the attribute to a speed already above one, so Efficiency does
nothing for a tool that is the wrong tool for the block.

Dig Speed, Mining Fatigue, being underwater without Aqua Affinity and
being off the ground are the four other terms of Java's formula, and
none of them is modeled: there is no effect system and no swimming state
on an entity.

#### Parameters

##### block

`string`

The block identifier being mined.

#### Returns

`number`

A multiplier on the base rate; 1 for a bare hand or an item
  with no rule for the block, which is Java's `Item.getDestroySpeed`.

#### Java Source

Player.getDestroySpeed

#### Java Source

Item.getDestroySpeed

***

### getName()

> **getName**(): `string`

Defined in: [packages/prismarine/src/item/Item.ts:312](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L312)

#### Returns

`string`

***

### getRuntimeId()

> **getRuntimeId**(): `number`

Defined in: [packages/prismarine/src/item/Item.ts:371](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L371)

The Bedrock runtime id for this item under the canonical numbering, the newest release's.

What everything off the wire means by an item's number. A stack going to a client is
numbered by `Item.wireId` against that session's own table instead, because the
two disagree for 82 items from 1.26.60 on.

#### Returns

`number`

***

### getTags()

> **getTags**(): readonly `string`[]

Defined in: [packages/prismarine/src/item/Item.ts:322](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L322)

The Bedrock tags attached to this item type, or an empty list when it has no type.

#### Returns

readonly `string`[]

***

### harvests()

> **harvests**(`block`, `content?`): `boolean`

Defined in: [packages/prismarine/src/item/Item.ts:711](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L711)

Whether swinging this harvests a block rather than destroying it for
nothing.

Java's `minecraft:tool` rules in one pass: the first rule whose block
set matches and whose `correct_for_drops` is stated decides, which is
how `#minecraft:incorrect_for_stone_tool` stops a stone pickaxe mining
diamond while `#minecraft:mineable/pickaxe` lets it mine stone.

#### Parameters

##### block

`string`

The block identifier being mined.

##### content?

[`ServerContent`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/ServerContent/index.md#servercontent) \| `undefined` = `...`

The content whose merged tags resolve this rule, defaulting to this stack's content.

#### Returns

`boolean`

False for a bare name no rule covers, which is Java's answer too.

***

### hasComponent()

> **hasComponent**(`name`): `boolean`

Defined in: [packages/prismarine/src/item/Item.ts:360](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L360)

Whether the resolved item type declares the named data component.

#### Parameters

##### name

`string`

#### Returns

`boolean`

***

### hasEnchantment()

> **hasEnchantment**(`enchantment`): `boolean`

Defined in: [packages/prismarine/src/item/Item.ts:674](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L674)

Whether the stack carries an enchantment at any level.

#### Parameters

##### enchantment

`string`

A namespaced or bare Java enchantment id. This took
  `ItemEnchantmentType` and always answered false; the enum numbers
  Bedrock's 37 enchantments, gives two of them the same number, and has
  nothing to say about the other six or about a datapack's.

#### Returns

`boolean`

***

### hasJavaTag()

> **hasJavaTag**(`tag`): `boolean`

Defined in: [packages/prismarine/src/item/Item.ts:341](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L341)

Whether a Java datapack tag includes this item type.

#### Parameters

##### tag

`string`

#### Returns

`boolean`

***

### hasTag()

> **hasTag**(`tag`): `boolean`

Defined in: [packages/prismarine/src/item/Item.ts:327](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L327)

Whether this item type carries one of its Bedrock tags.

#### Parameters

##### tag

`string`

#### Returns

`boolean`

***

### isArmorPiece()

> **isArmorPiece**(): `boolean`

Defined in: [packages/prismarine/src/item/Item.ts:436](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L436)

Whether the item's components give it an armor value.

#### Returns

`boolean`

***

### isPartOfCreativeInventory()

> **isPartOfCreativeInventory**(): `boolean`

Defined in: [packages/prismarine/src/item/Item.ts:694](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L694)

#### Returns

`boolean`

***

### isTool()

> **isTool**(): `boolean`

Defined in: [packages/prismarine/src/item/Item.ts:431](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L431)

Whether the item's components make it a tool.

#### Returns

`boolean`

***

### networkSerialize()

> **networkSerialize**(`stream`, `stackNetId?`): `void`

Defined in: [packages/prismarine/src/item/Item.ts:847](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L847)

Writes an item stack in the form that carries a stack net id - an `ItemInstance`.

There are two forms on the wire, and at 2168 they no longer differ by one byte. This
one, which an inventory, an equipped hand or a transaction carries, opens with a
**fixed two byte id** and closes with an *unsigned* block runtime id; the other,
[networkSerializeWithoutStackId](#networkserializewithoutstackid), uses a varint for both. Neither still stops
early for air: up to 748 a zero id was the whole stack, and now every field is written
whatever the id is. An inventory is mostly empty slots, so a stack that stops after the
id truncates the packet almost immediately - which is exactly what the client reports
as a bad packet on join, before any of the interesting packets are even reached.

#### Parameters

##### stream

[`BinaryStream`](https://jsprismarine.dev/api/@jsprismarine/binaryutils/classes/BinaryStream.md)

the stream to write to.

##### stackNetId?

`number` \| `null` = `null`

the stack's net id, when the receiver tracks one.

#### Returns

`void`

#### See

https://mojang.github.io/bedrock-protocol-docs/1.26.51/types/network-item-stack-descriptor/

***

### networkSerializeWithoutStackId()

> **networkSerializeWithoutStackId**(`stream`): `void`

Defined in: [packages/prismarine/src/item/Item.ts:885](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L885)

Writes an item stack in the form that carries no stack net id - an `ItemStack`.

What the creative menu and every recipe carries, because nothing is tracking these
stacks. See [networkSerialize](#networkserialize) for how the two forms differ beyond the flag.

#### Parameters

##### stream

[`BinaryStream`](https://jsprismarine.dev/api/@jsprismarine/binaryutils/classes/BinaryStream.md)

#### Returns

`void`

***

### rawComponent()

> **rawComponent**(`name`): `unknown`

Defined in: [packages/prismarine/src/item/Item.ts:352](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L352)

A data component as this stack carries it, or else as its item type's definition writes it,
unparsed, for a rule that reads a field the parsed component leaves out, such as a totem's
`death_effects`.

#### Parameters

##### name

`string`

#### Returns

`unknown`

***

### toStackDescriptor()

> **toStackDescriptor**(`source`, `stackNetId?`): [`ItemStackDescriptorData`](https://jsprismarine.dev/api/@jsprismarine/protocol/index.md#itemstackdescriptordata)

Defined in: [packages/prismarine/src/item/Item.ts:861](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L861)

This stack as the six wire fields of a `NetworkItemStackDescriptor`.

The server converts its game item into this protocol DTO at the package boundary; the
protocol package writes the bytes. An empty stack zeroes every field after the id, as
[networkSerialize](#networkserialize) always has.

#### Parameters

##### source

[`BinaryStream`](https://jsprismarine.dev/api/@jsprismarine/binaryutils/classes/BinaryStream.md) \| [`ProtocolContext`](https://jsprismarine.dev/api/@jsprismarine/protocol/index.md#protocolcontext)

The packet stream or negotiated protocol context that selects item numbering.

##### stackNetId?

`number` \| `null` = `null`

The stack's net id, when the receiver tracks one.

#### Returns

[`ItemStackDescriptorData`](https://jsprismarine.dev/api/@jsprismarine/protocol/index.md#itemstackdescriptordata)

The descriptor the stack goes out as.

***

### userDataTag()

> **userDataTag**(): [`NBTTagCompound`](https://jsprismarine.dev/api/@jsprismarine/nbt/classes/NBTTagCompound.md) \| `null`

Defined in: [packages/prismarine/src/item/Item.ts:930](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L930)

What the client is told about this stack beyond its id, count and aux value.

The enchantments, the name, the lore and the durability spent, in the shape
`itemUserDataTag` lays out. Null for a stack with none of them and no durability,
which is most of them and every slot of an untouched inventory.

#### Returns

[`NBTTagCompound`](https://jsprismarine.dev/api/@jsprismarine/nbt/classes/NBTTagCompound.md) \| `null`

***

### withComponents()

> **withComponents**(`changes`): `Item`

Defined in: [packages/prismarine/src/item/Item.ts:549](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L549)

A copy of this stack with some of its other components set.

#### Parameters

##### changes

`Readonly`\<`Record`\<`string`, `unknown`\>\>

Component ids and values. An undefined value removes the component, and a
  component the stack holds in a field of its own is left out.

#### Returns

`Item`

***

### withContents()

> **withContents**(`contents`): `Item`

Defined in: [packages/prismarine/src/item/Item.ts:565](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L565)

A copy of this stack holding different contents.

#### Parameters

##### contents

readonly (`Item` \| `null`)[]

One entry per slot, null for an empty one.

#### Returns

`Item`

***

### withCount()

> **withCount**(`count`): `Item`

Defined in: [packages/prismarine/src/item/Item.ts:621](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L621)

A copy of this stack holding a different number of items.

Everything else comes along: the enchantments, the durability spent, the name, the lore,
the contents and the content the stack reads its components from. A slot that changes
size goes through here, because the wire writes the item's count and not the slot's.

The stack network id comes along too, because a stack that grows or shrinks is still the
stack the client knows: an unpinned Bedrock Dedicated Server keeps the id on what is left
of a stack and on a stack merged onto. A part split off is a new stack, and the caller
clears the id on it.

#### Parameters

##### count

`number`

How many the copy holds. Set after construction, so zero stays zero.

#### Returns

`Item`

***

### withDisplay()

> **withDisplay**(`customName`, `lore?`): `Item`

Defined in: [packages/prismarine/src/item/Item.ts:603](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L603)

A copy of this stack with a different name and lore.

#### Parameters

##### customName

`string` \| `undefined`

The new name, or undefined to go back to the item's own.

##### lore?

readonly `string`[] = `...`

#### Returns

`Item`

***

### withDurability()

> **withDurability**(`durability`): `Item`

Defined in: [packages/prismarine/src/item/Item.ts:636](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L636)

A copy of this stack with `durability` left, which is how a tool wears.

A copy and not a change in place, so the slot that holds the stack is written and the
change log hears it. The stack network id comes along, as [Item.withCount](#withcount) keeps it.

#### Parameters

##### durability

`number`

The durability the copy has left.

#### Returns

`Item`

***

### withEnchantments()

> **withEnchantments**(`levels`): `Item`

Defined in: [packages/prismarine/src/item/Item.ts:594](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L594)

A copy of this stack carrying a different enchantment set.

A copy rather than a mutation: the anvil and the enchanting table both
compute a result before the player has paid for it, and a stack enchanted
in place would have been enchanted whether they paid or not.

#### Parameters

##### levels

`Readonly`\<`Record`\<`string`, `number`\>\> \| `ReadonlyMap`\<`string`, `number`\>

#### Returns

`Item`

***

### withMapId()

> **withMapId**(`mapId`): `Item`

Defined in: [packages/prismarine/src/item/Item.ts:574](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L574)

A copy of this stack showing a different saved map.

#### Parameters

##### mapId

`number`

The map's id in its level, Java's `minecraft:map_id`.

#### Returns

`Item`

***

### withMeta()

> **withMeta**(`meta`): `Item`

Defined in: [packages/prismarine/src/item/Item.ts:583](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L583)

A copy of this stack with a different legacy auxiliary value.

#### Parameters

##### meta

`number`

The replacement auxiliary value, such as a transformed entity-interaction item.

#### Returns

`Item`

***

### air()

> `static` **air**(): `Item`

Defined in: [packages/prismarine/src/item/Item.ts:817](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L817)

The empty stack.

A count of zero as well as the air name, because at 2168 an empty stack still writes its
count - so an "empty" stack holding one of something says the slot has one air in it.

#### Returns

`Item`

***

### fromStackDescriptor()

> `static` **fromStackDescriptor**(`source`, `descriptor`): `Item`

Defined in: [packages/prismarine/src/item/Item.ts:1014](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L1014)

The stack a `NetworkItemStackDescriptor` describes.

Resolves the wire descriptor returned by a protocol packet into the server's game item.

#### Parameters

##### source

[`BinaryStream`](https://jsprismarine.dev/api/@jsprismarine/binaryutils/classes/BinaryStream.md) \| [`ProtocolContext`](https://jsprismarine.dev/api/@jsprismarine/protocol/index.md#protocolcontext)

The packet stream or negotiated protocol context that selects item numbering.

##### descriptor

[`ItemStackDescriptorData`](https://jsprismarine.dev/api/@jsprismarine/protocol/index.md#itemstackdescriptordata)

The six wire fields.

#### Returns

`Item`

The stack, with an unknown id kept so it goes back out as the client sent it.

***

### networkDeserialize()

> `static` **networkDeserialize**(`stream`): `Item`

Defined in: [packages/prismarine/src/item/Item.ts:1002](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L1002)

Reads an item stack off the wire.

The layout is `NetworkItemStackDescriptor`, which `@jsprismarine/protocol` already
describes: the id, the count, the aux value, an **always present** flag saying whether
a stack net id follows, the block runtime id, and one length prefixed blob holding the
nbt and the can-place-on / can-break lists. All of it, even for air.

The block lists are retained so a stack the client sends can be sent back with the same
adventure-mode restrictions. The NBT compound and optional shield blocking tick remain
unused here; the user-data structure isolates them from the following packet fields.

Reading the flag is what keeps every field after it aligned. It used to be read only
when a caller asked for `extra`, which no caller ever did, so from that byte onwards
the reader was one out: the lists it then walked had garbage lengths, ran off the end
of the buffer and threw. Every InventoryTransaction died there - which is what left a
survival block break with no sound, the packet never reaching its handler.

#### Parameters

##### stream

[`BinaryStream`](https://jsprismarine.dev/api/@jsprismarine/binaryutils/classes/BinaryStream.md)

#### Returns

`Item`

#### See

https://mojang.github.io/bedrock-protocol-docs/1.26.51/types/network-item-stack-descriptor/

***

### networkDeserializeWithoutStackId()

> `static` **networkDeserializeWithoutStackId**(`stream`): `Item`

Defined in: [packages/prismarine/src/item/Item.ts:1052](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/Item.ts#L1052)

Reads the form that carries no stack net id - the creative menu's.

The counterpart to [networkSerializeWithoutStackId](#networkserializewithoutstackid); see it for why the two
forms exist and what confusing them costs.

#### Parameters

##### stream

[`BinaryStream`](https://jsprismarine.dev/api/@jsprismarine/binaryutils/classes/BinaryStream.md)

#### Returns

`Item`
