Skip to content

API reference / @jsprismarine/prismarine / world/positionKeys

world/positionKeys ​

Type Aliases ​

BlockPositionKey ​

BlockPositionKey = bigint | string

Defined in: packages/prismarine/src/world/positionKeys.ts:5

Exact key for one world block position.


CoordinatePairKey ​

CoordinatePairKey = number | string

Defined in: packages/prismarine/src/world/positionKeys.ts:2

A compact key for coordinate pairs, with a collision-free string fallback.

Functions ​

blockPositionKey() ​

blockPositionKey(x, y, z): BlockPositionKey

Defined in: packages/prismarine/src/world/positionKeys.ts:80

Packs a supported integer block position into one exact integer key.

The world border needs 26 bits each for x and z, and the supported vertical range needs 12 for y, which exceeds JavaScript's 53-bit number precision. BigInt keeps the existing one-map deduplication and insertion order while avoiding a string allocation for ordinary blocks.

Parameters ​

x ​

number

World x.

y ​

number

World y.

z ​

number

World z.

Returns ​

BlockPositionKey

An exact integer key, or a string for out-of-range positions.


blockPositionKeys() ​

blockPositionKeys(x, y, z): object

Defined in: packages/prismarine/src/world/positionKeys.ts:50

The chunk and local position keys for one block coordinate.

The nested keys keep the full supported world border and height unique without allocating a string per block. Unusual heights and fractional coordinates retain exact string identities.

Parameters ​

x ​

number

World x.

y ​

number

World y.

z ​

number

World z.

Returns ​

object

The packed chunk and local keys.

chunk ​

readonly chunk: CoordinatePairKey

position ​

readonly position: CoordinatePairKey


coordinatePairKey() ​

coordinatePairKey(first, second): CoordinatePairKey

Defined in: packages/prismarine/src/world/positionKeys.ts:26

Packs two in-range integer coordinates without losing identity.

The fallback is kept as a string because JavaScript numbers cannot exactly represent every coordinate pair outside this range. Numeric and string Map keys occupy separate key domains.

Parameters ​

first ​

number

The first coordinate.

second ​

number

The second coordinate.

Returns ​

CoordinatePairKey

A numeric key, or the exact coordinate pair as a string.