Skip to content

API reference / @jsprismarine/prismarine / item/contentAdapter

item/contentAdapter ​

Interfaces ​

ContentItemGroupOptions ​

Defined in: packages/prismarine/src/item/contentAdapter.ts:152

What createContentItemGroup is built over.

Properties ​

actors ​

readonly actors: ItemActorPort

Defined in: packages/prismarine/src/item/contentAdapter.ts:161

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

blocks ​

readonly blocks: ContentBlockGroup

Defined in: packages/prismarine/src/item/contentAdapter.ts:154

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

content ​

readonly content: ContentLookup

Defined in: packages/prismarine/src/item/contentAdapter.ts:163

The built content, read at call time; see ContentLookup.

effects ​

readonly effects: ContentEffectSink

Defined in: packages/prismarine/src/item/contentAdapter.ts:156

entities ​

readonly entities: ContentEntityAccess

Defined in: packages/prismarine/src/item/contentAdapter.ts:155

level ​

readonly level: ContentLevelFacts

Defined in: packages/prismarine/src/item/contentAdapter.ts:157

levelName? ​

readonly optional levelName?: string

Defined in: packages/prismarine/src/item/contentAdapter.ts:159

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

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

Parameters ​
base ​

BlockPosition

Returns ​

boolean

potions? ​

readonly optional potions?: PotionEffects

Defined in: packages/prismarine/src/item/contentAdapter.ts:169

tieLeashes? ​

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

Defined in: packages/prismarine/src/item/contentAdapter.ts:167

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

Parameters ​
source ​

ItemSource

fence ​

BlockPosition

Returns ​

boolean

transformers? ​

readonly optional transformers?: BlockTransformers

Defined in: packages/prismarine/src/item/contentAdapter.ts:168


ItemActorPort ​

Defined in: packages/prismarine/src/item/contentAdapter.ts:93

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 ​

Methods ​

boostMount()? ​

optional boostMount(source, item): boolean

Defined in: packages/prismarine/src/item/contentAdapter.ts:107

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

Parameters ​
source ​

ItemSource

item ​

string

Returns ​

boolean

canDyeEntity()? ​

optional canDyeEntity(target, color): boolean

Defined in: packages/prismarine/src/item/contentAdapter.ts:111

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

Parameters ​
target ​

ItemSource

color ​

string

Returns ​

boolean

canNameEntity()? ​

optional canNameEntity(target): boolean

Defined in: packages/prismarine/src/item/contentAdapter.ts:109

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

Parameters ​
target ​

ItemSource

Returns ​

boolean

entityFits()? ​

optional entityFits(identifier, position): boolean

Defined in: packages/prismarine/src/item/contentAdapter.ts:119

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

Parameters ​
identifier ​

string

position ​

BlockPosition

Returns ​

boolean

eyesInEntity()? ​

optional eyesInEntity(source): boolean

Defined in: packages/prismarine/src/item/contentAdapter.ts:117

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

Parameters ​
source ​

ItemSource

Returns ​

boolean

locate()? ​

optional locate(destination, origin): BlockPosition | undefined

Defined in: packages/prismarine/src/item/contentAdapter.ts:113

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

Parameters ​
destination ​

string

origin ​

BlockPosition

Returns ​

BlockPosition | undefined

perform() ​

perform(action): void

Defined in: packages/prismarine/src/item/contentAdapter.ts:123

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

Parameters ​
action ​

ActorItemAction

Returns ​

void

stateOf() ​

stateOf(source): SourceState

Defined in: packages/prismarine/src/item/contentAdapter.ts:95

Everything a behavior reads about the entity using the item.

Parameters ​
source ​

ItemSource

Returns ​

SourceState

supports()? ​

optional supports(action): boolean

Defined in: packages/prismarine/src/item/contentAdapter.ts:121

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 | undefined

Defined in: packages/prismarine/src/item/contentAdapter.ts:97

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

Parameters ​
source ​

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 | undefined

targetOf() ​

targetOf(source): ItemSource | undefined

Defined in: packages/prismarine/src/item/contentAdapter.ts:105

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

Parameters ​
source ​

ItemSource

Returns ​

ItemSource | undefined

viewHit()? ​

optional viewHit(source, fluid): ViewHit | undefined

Defined in: packages/prismarine/src/item/contentAdapter.ts:115

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

Parameters ​
source ​

ItemSource

fluid ​

FluidClip

Returns ​

ViewHit | undefined

Type Aliases ​

ActorItemAction ​

ActorItemAction = Exclude<ItemWorldAction, WorldItemAction>

Defined in: packages/prismarine/src/item/contentAdapter.ts:81

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 is what forces a decision about it.


BlockTransformers ​

BlockTransformers = (transformer, block, face) => BlockPlacement | undefined

Defined in: packages/prismarine/src/item/contentAdapter.ts:136

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 & object

face ​

BlockFace

Returns ​

BlockPlacement | undefined


PotionEffects ​

PotionEffects = (potion) => readonly EffectApplication[]

Defined in: packages/prismarine/src/item/contentAdapter.ts:149

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[]


WorldItemAction ​

WorldItemAction = ItemWorldActionOf<typeof WORLD_ITEM_ACTION_KINDS[number]>

Defined in: packages/prismarine/src/item/contentAdapter.ts:72

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

The kinds whose subject is a place in the world rather than an entity.

Functions ​

createContentItemGroup() ​

createContentItemGroup(options): ContentItemAccess

Defined in: packages/prismarine/src/item/contentAdapter.ts:185

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

Parameters ​

options ​

ContentItemGroupOptions

Returns ​

ContentItemAccess

Throws ​

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