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

# item/contentAdapter

## Interfaces

### ContentItemGroupOptions

Defined in: [packages/prismarine/src/item/contentAdapter.ts:152](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L152)

What [createContentItemGroup](#createcontentitemgroup) is built over.

#### Properties

##### actors

> `readonly` **actors**: [`ItemActorPort`](#itemactorport)

Defined in: [packages/prismarine/src/item/contentAdapter.ts:161](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L161)

The entity-facing half of the union, plus the two queries about the user.

##### blocks

> `readonly` **blocks**: [`ContentBlockGroup`](https://jsprismarine.dev/api/@jsprismarine/prismarine/block/contentAdapter/index.md#contentblockgroup)

Defined in: [packages/prismarine/src/item/contentAdapter.ts:154](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L154)

The block group this subsystem also owns, which the four block variants go through.

##### content

> `readonly` **content**: [`ContentLookup`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/views/index.md#contentlookup)

Defined in: [packages/prismarine/src/item/contentAdapter.ts:163](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L163)

The built content, read at call time; see [ContentLookup](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/views/index.md#contentlookup).

##### effects

> `readonly` **effects**: [`ContentEffectSink`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contenteffectsink)

Defined in: [packages/prismarine/src/item/contentAdapter.ts:156](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L156)

##### entities

> `readonly` **entities**: [`ContentEntityAccess`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contententityaccess)

Defined in: [packages/prismarine/src/item/contentAdapter.ts:155](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L155)

##### level

> `readonly` **level**: [`ContentLevelFacts`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentlevelfacts)

Defined in: [packages/prismarine/src/item/contentAdapter.ts:157](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L157)

##### levelName?

> `readonly` `optional` **levelName?**: `string`

Defined in: [packages/prismarine/src/item/contentAdapter.ts:159](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L159)

The name of the level this group covers, which the block hooks carry; left out for the default level.

##### placeEndCrystal?

> `readonly` `optional` **placeEndCrystal?**: (`base`) => `boolean`

Defined in: [packages/prismarine/src/item/contentAdapter.ts:165](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L165)

Places an end crystal after the host validates its support and spawn volume.

###### Parameters

###### base

[`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#blockposition)

###### Returns

`boolean`

##### potions?

> `readonly` `optional` **potions?**: [`PotionEffects`](#potioneffects)

Defined in: [packages/prismarine/src/item/contentAdapter.ts:169](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L169)

##### tieLeashes?

> `readonly` `optional` **tieLeashes?**: (`source`, `fence`) => `boolean`

Defined in: [packages/prismarine/src/item/contentAdapter.ts:167](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L167)

Ties a player's leashed mobs to a fence, through the entity runtime.

###### Parameters

###### source

[`ItemSource`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#itemsource)

###### fence

[`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#blockposition)

###### Returns

`boolean`

##### transformers?

> `readonly` `optional` **transformers?**: [`BlockTransformers`](#blocktransformers)

Defined in: [packages/prismarine/src/item/contentAdapter.ts:168](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L168)

***

### ItemActorPort

Defined in: [packages/prismarine/src/item/contentAdapter.ts:93](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L93)

What only the subsystems holding the entity index and the player sessions
can answer or do.

Three required members rather than one per action: the half of the union
this port owns stays a union, so adding an effect is a new case in its
switch. Optional capability queries let a behavior check whether an entity
accepts a name tag or dye, or whether the port performs an action kind at
all, before it consumes the item.

#### Extended by

- [`ServerItemActorPort`](https://jsprismarine.dev/api/@jsprismarine/prismarine/item/actorPort/index.md#serveritemactorport)

#### Methods

##### boostMount()?

> `optional` **boostMount**(`source`, `item`): `boolean`

Defined in: [packages/prismarine/src/item/contentAdapter.ts:107](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L107)

Boosts the mount the user steers with the item, and says whether it did, when the host has mounts.

###### Parameters

###### source

[`ItemSource`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#itemsource)

###### item

`string`

###### Returns

`boolean`

##### canDyeEntity()?

> `optional` **canDyeEntity**(`target`, `color`): `boolean`

Defined in: [packages/prismarine/src/item/contentAdapter.ts:111](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L111)

Whether a target entity accepts this dye, when the host can answer.

###### Parameters

###### target

[`ItemSource`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#itemsource)

###### color

`string`

###### Returns

`boolean`

##### canNameEntity()?

> `optional` **canNameEntity**(`target`): `boolean`

Defined in: [packages/prismarine/src/item/contentAdapter.ts:109](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L109)

Whether a target entity accepts a name tag, when the host can answer.

###### Parameters

###### target

[`ItemSource`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#itemsource)

###### Returns

`boolean`

##### entityFits()?

> `optional` **entityFits**(`identifier`, `position`): `boolean`

Defined in: [packages/prismarine/src/item/contentAdapter.ts:119](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L119)

Whether a new entity of a type would stand clear at a position; see `WorldActions.entityFits`.

###### Parameters

###### identifier

`string`

###### position

[`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#blockposition)

###### Returns

`boolean`

##### eyesInEntity()?

> `optional` **eyesInEntity**(`source`): `boolean`

Defined in: [packages/prismarine/src/item/contentAdapter.ts:117](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L117)

Whether the source's eyes are inside an entity it could pick; see `WorldActions.eyesInEntity`.

###### Parameters

###### source

[`ItemSource`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#itemsource)

###### Returns

`boolean`

##### locate()?

> `optional` **locate**(`destination`, `origin`): [`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#blockposition) \| `undefined`

Defined in: [packages/prismarine/src/item/contentAdapter.ts:113](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L113)

The nearest structure in a structure tag, when the host has a structure search.

###### Parameters

###### destination

`string`

###### origin

[`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#blockposition)

###### Returns

[`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#blockposition) \| `undefined`

##### perform()

> **perform**(`action`): `void`

Defined in: [packages/prismarine/src/item/contentAdapter.ts:123](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L123)

Does one thing to an entity, an inventory or a screen.

###### Parameters

###### action

[`ActorItemAction`](#actoritemaction)

###### Returns

`void`

##### stateOf()

> **stateOf**(`source`): [`SourceState`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#sourcestate)

Defined in: [packages/prismarine/src/item/contentAdapter.ts:95](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L95)

Everything a behavior reads about the entity using the item.

###### Parameters

###### source

[`ItemSource`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#itemsource)

###### Returns

[`SourceState`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#sourcestate)

##### supports()?

> `optional` **supports**(`action`): `boolean`

Defined in: [packages/prismarine/src/item/contentAdapter.ts:121](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L121)

Whether the port performs an action of this kind, when it can say.

###### Parameters

###### action

`"map"` \| `"ignite"` \| `"brush"` \| `"blocking"` \| `"fishing"` \| `"signal"` \| `"place-block"` \| `"break-block"` \| `"spawn-entity"` \| `"launch-firework"` \| `"launch-projectile"` \| `"play-sound"` \| `"play-block-sound"` \| `"apply-effects"` \| `"remove-effects"` \| `"damage-entity"` \| `"feed"` \| `"teleport-randomly"` \| `"grant-experience"` \| `"start-cooldown"` \| `"consume-durability"` \| `"give-item"` \| `"equip"` \| `"name-entity"` \| `"attach-lead"` \| `"dye-entity"` \| `"shear-entity"` \| `"disable-shield"` \| `"open-screen"`

###### Returns

`boolean`

##### takeAmmo()?

> `optional` **takeAmmo**(`source`, `accepted`, `keeps`, `heldOnly?`): [`AmmoStack`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#ammostack) \| `undefined`

Defined in: [packages/prismarine/src/item/contentAdapter.ts:97](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L97)

Finds and takes the ammo a shot fires; see `ItemWorld.takeAmmo`.

###### Parameters

###### source

[`ItemSource`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#itemsource)

###### accepted

readonly `string`[]

###### keeps

(`identifier`) => `boolean`

###### heldOnly?

readonly `string`[]

Ammo taken only from a hand, as a crossbow takes a firework rocket.

###### Returns

[`AmmoStack`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#ammostack) \| `undefined`

##### targetOf()

> **targetOf**(`source`): [`ItemSource`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#itemsource) \| `undefined`

Defined in: [packages/prismarine/src/item/contentAdapter.ts:105](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L105)

The entity an interaction landed on, or undefined when it landed on a block or nothing.

###### Parameters

###### source

[`ItemSource`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#itemsource)

###### Returns

[`ItemSource`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#itemsource) \| `undefined`

##### viewHit()?

> `optional` **viewHit**(`source`, `fluid`): [`ViewHit`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#viewhit-2) \| `undefined`

Defined in: [packages/prismarine/src/item/contentAdapter.ts:115](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L115)

Where the source's view first meets a block, stopping at the fluids named; see `WorldActions.viewHit`.

###### Parameters

###### source

[`ItemSource`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#itemsource)

###### fluid

[`FluidClip`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#fluidclip)

###### Returns

[`ViewHit`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#viewhit-2) \| `undefined`

## Type Aliases

### ActorItemAction

> **ActorItemAction** = `Exclude`\<[`ItemWorldAction`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#itemworldaction), [`WorldItemAction`](#worlditemaction)\>

Defined in: [packages/prismarine/src/item/contentAdapter.ts:81](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L81)

An action whose subject is an entity, an inventory or a screen.

Derived rather than listed, so a new variant of `ItemWorldAction` joins
this half by default and the exhaustive switch in
[createContentItemGroup](#createcontentitemgroup) is what forces a decision about it.

***

### BlockTransformers

> **BlockTransformers** = (`transformer`, `block`, `face`) => [`BlockPlacement`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#blockplacement) \| `undefined`

Defined in: [packages/prismarine/src/item/contentAdapter.ts:136](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L136)

What a `minecraft:block_transformer` turns a block into.

Injected rather than computed here, because the table is Java's own
`block_transformer` registry and `src/item/blockTransformers.ts` resolves
it over the built content; the server wires that resolver in. The default
answers nothing for every block, which is the interface's own "this
transformer has no rule here", so an axe declines to strip rather than
stripping a log into something guessed.

#### Parameters

##### transformer

`string`

##### block

[`ContentBlock`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentblock) & `object`

##### face

[`BlockFace`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#blockface)

#### Returns

[`BlockPlacement`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#blockplacement) \| `undefined`

***

### PotionEffects

> **PotionEffects** = (`potion`) => readonly [`EffectApplication`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#effectapplication)[]

Defined in: [packages/prismarine/src/item/contentAdapter.ts:149](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L149)

The effects one potion identifier applies.

Injected for the same reason: Java keeps its 47 potions in code, in
`Potions`, so no pack publishes them and the server has to answer. The
default is the empty list, which is also what a water bottle gives.

#### Parameters

##### potion

`string`

#### Returns

readonly [`EffectApplication`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#effectapplication)[]

***

### WorldItemAction

> **WorldItemAction** = [`ItemWorldActionOf`](https://jsprismarine.dev/api/@jsprismarine/item-behaviors/index.md#itemworldactionof)\<*typeof* [`WORLD_ITEM_ACTION_KINDS`](#world-item-action-kinds)\[`number`\]\>

Defined in: [packages/prismarine/src/item/contentAdapter.ts:72](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L72)

An action this subsystem performs itself, over the block, entity and effect groups.

## Variables

### WORLD\_ITEM\_ACTION\_KINDS

> `const` **WORLD\_ITEM\_ACTION\_KINDS**: readonly \[`"place-block"`, `"break-block"`, `"ignite"`, `"play-sound"`, `"play-block-sound"`, `"spawn-entity"`\]

Defined in: [packages/prismarine/src/item/contentAdapter.ts:59](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L59)

The `kind`s whose subject is a place in the world rather than an entity.

## Functions

### createContentItemGroup()

> **createContentItemGroup**(`options`): [`ContentItemAccess`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentitemaccess)

Defined in: [packages/prismarine/src/item/contentAdapter.ts:185](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/item/contentAdapter.ts#L185)

Builds the `items` group over the block, entity and effect groups of one
dimension.

#### Parameters

##### options

[`ContentItemGroupOptions`](#contentitemgroupoptions)

#### Returns

[`ContentItemAccess`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentitemaccess)

#### Throws

Nothing here throws on its own; a member the actor port has
  not supplied throws from the port.
