Skip to content

API reference / @jsprismarine/prismarine / block/contentAdapter

block/contentAdapter ​

Interfaces ​

BlockEntityStore ​

Defined in: packages/prismarine/src/block/contentAdapter.ts:103

The block entity records of one dimension, which data and setData read and write.

Methods ​

at() ​

at(position): BlockEntityData | undefined

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

The record at a position, or undefined when the position carries none.

Parameters ​
position ​

ContentPosition

Returns ​

BlockEntityData | undefined

put() ​

put(position, data): void

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

Replaces the record at a position whole.

Parameters ​
position ​

ContentPosition

data ​

BlockEntityData

Returns ​

void


BlockStorageAccess ​

Defined in: packages/prismarine/src/block/contentAdapter.ts:69

Where the blocks of one dimension are kept.

Chunk storage answers the read and write directly. Movement is optional for adapters that can carry a block entity without running placement hooks.

Methods ​

at() ​

at(position): ContentBlock | undefined

Defined in: packages/prismarine/src/block/contentAdapter.ts:71

The block at a position, or undefined when the chunk holding it is not loaded.

Parameters ​
position ​

ContentPosition

Returns ​

ContentBlock | undefined

destroy()? ​

optional destroy(position, options?): boolean

Defined in: packages/prismarine/src/block/contentAdapter.ts:99

Raises a block's onBreak and puts what Java's table rolls on the ground, leaving the write to the caller; see ContentBlockAccess.destroy.

Optional because only a storage over a live world can do it: the drops a family makes while the hook runs have to be told apart from the table's own roll, which needs the world those drops go to.

Parameters ​
position ​

ContentPosition

options? ​

BlockDestroyOptions

Returns ​

boolean

liquidAt()? ​

optional liquidAt(position): ContentBlock | undefined

Defined in: packages/prismarine/src/block/contentAdapter.ts:85

The liquid a position holds in its second storage layer, which is where Bedrock keeps a waterlogged block's water, or undefined when there is none.

Parameters ​
position ​

ContentPosition

Returns ​

ContentBlock | undefined

move()? ​

optional move(from, to): void

Defined in: packages/prismarine/src/block/contentAdapter.ts:80

Moves a block and its block entity without raising placement hooks.

Parameters ​
from ​

ContentPosition

to ​

ContentPosition

Returns ​

void

write() ​

write(position, block): void

Defined in: packages/prismarine/src/block/contentAdapter.ts:78

Writes a block, raising no hook and notifying no neighbor.

createContentBlockGroup layers both of those on top, so a storage that does either as well would do it twice.

Parameters ​
position ​

ContentPosition

block ​

ContentBlock

Returns ​

void

writeLiquid()? ​

optional writeLiquid(position, liquid): void

Defined in: packages/prismarine/src/block/contentAdapter.ts:90

Writes the liquid a position holds in its second storage layer, or takes it away for undefined, raising no hook and notifying no neighbor.

Parameters ​
position ​

ContentPosition

liquid ​

ContentBlock | undefined

Returns ​

void


ContentBlockGroupOptions ​

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

What createContentBlockGroup is built over.

Properties ​

blockEntities ​

readonly blockEntities: BlockEntityStore

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

content ​

readonly content: ContentLookup

Defined in: packages/prismarine/src/block/contentAdapter.ts:120

The built content, read at call time.

The content is built around this adapter, so it does not exist when the group is constructed. Same reason contentWorldViews takes a lookup.

dimension? ​

readonly optional dimension?: string

Defined in: packages/prismarine/src/block/contentAdapter.ts:122

The dimension this group covers, which the block hooks carry.

level? ​

readonly optional level?: string

Defined in: packages/prismarine/src/block/contentAdapter.ts:124

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

storage ​

readonly storage: BlockStorageAccess

Defined in: packages/prismarine/src/block/contentAdapter.ts:112

updateEngineAround? ​

readonly optional updateEngineAround?: (at, block) => void

Defined in: packages/prismarine/src/block/contentAdapter.ts:126

Runs the engine systems when a content block announces that it changed.

Parameters ​
at ​

ContentPosition

block ​

ContentBlock

Returns ​

void

updateEngineAt? ​

readonly optional updateEngineAt?: (at, from) => void

Defined in: packages/prismarine/src/block/contentAdapter.ts:132

Runs the engine systems on one block whose neighbor changed.

Parameters ​
at ​

ContentPosition

from ​

ContentBlock

Returns ​

void

Java See ​

Level.neighborChanged(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/redstone/Orientation;)V

Type Aliases ​

ContentBlockGroup ​

ContentBlockGroup = Pick<ContentBlockAccess, "get" | "liquid" | "set" | "move" | "destroy" | "data" | "setData" | "notifyNeighbors" | "notifyNeighbor" | "updateNeighborForOutputSignal" | "updateShape" | "power" | "powerToWire" | "wireShape" | "signal" | "directSignal" | "isRedstoneConductor" | "executeEntityEvent">

Defined in: packages/prismarine/src/block/contentAdapter.ts:41

The members of ContentBlockAccess the block and item subsystem implements.

Functions ​

createContentBlockGroup() ​

createContentBlockGroup(options): ContentBlockGroup

Defined in: packages/prismarine/src/block/contentAdapter.ts:231

Builds the eight block adapter members over one dimension's storage.

set commits the write before it raises onPlace, because the hook is documented to run with the new state already readable, and notifies the neighbors afterwards so a behavior that writes its own state during onPlace has done so before anything reads it back.

A write that leaves the same block standing raises onBlockStateChange instead of onPlace, once per state value that moved. That is what the two hooks are documented to mean, and it is also what makes the write terminate: a door opens by rewriting its own open_bit, so onPlace would call the family that is calling it.

Parameters ​

options ​

ContentBlockGroupOptions

Returns ​

ContentBlockGroup