API reference / @jsprismarine/blocks / BlockPalette
Class: BlockPalette
Defined in: packages/blocks/src/state.ts:155
Every block the server knows and a dense runtime id per state.
Ids are positional, assigned by walking the blocks in identifier order and each block's states in canonical index order, so the same palette input reproduces every id. They are not the FNV-1a hashes the network carries; those stay in the protocol layer. These are the array indices the flattened tables and the chunk storage read.
Constructors
Constructor
new BlockPalette(
blocks):BlockPalette
Defined in: packages/blocks/src/state.ts:164
Parameters
blocks
Iterable<readonly [string, BlockStateModel]>
Identifier to state model, in any order; the palette sorts by identifier.
Returns
BlockPalette
Properties
entries
readonlyentries: readonlyPaletteEntry[]
Defined in: packages/blocks/src/state.ts:157
The blocks in identifier order.
stateCount
readonlystateCount:number
Defined in: packages/blocks/src/state.ts:159
How many states the palette holds, which is the length of a flattened column.
Methods
entry()
entry(
identifier):PaletteEntry|undefined
Defined in: packages/blocks/src/state.ts:184
One block's entry, or undefined when the palette has no such identifier.
Parameters
identifier
string
Returns
PaletteEntry | undefined
runtimeId()
runtimeId(
identifier,values?):number
Defined in: packages/blocks/src/state.ts:194
The dense runtime id of one state.
Parameters
identifier
string
values?
Readonly<Record<string, BlockStateValue>> = {}
Returns
number
Throws
When the palette has no such block, or the values do not name a state of it.
stateOf()
stateOf(
runtimeId):object
Defined in: packages/blocks/src/state.ts:205
Which block and state one dense runtime id stands for.
Parameters
runtimeId
number
Returns
object
entry
entry:
PaletteEntry
values
values:
Readonly<Record<string,BlockStateValue>>
Throws
When the id is not in [0, stateCount).