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

# world/positionKeys

## Type Aliases

### BlockPositionKey

> **BlockPositionKey** = `bigint` \| `string`

Defined in: [packages/prismarine/src/world/positionKeys.ts:5](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/positionKeys.ts#L5)

Exact key for one world block position.

***

### CoordinatePairKey

> **CoordinatePairKey** = `number` \| `string`

Defined in: [packages/prismarine/src/world/positionKeys.ts:2](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/positionKeys.ts#L2)

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

## Functions

### blockPositionKey()

> **blockPositionKey**(`x`, `y`, `z`): [`BlockPositionKey`](#blockpositionkey)

Defined in: [packages/prismarine/src/world/positionKeys.ts:80](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/positionKeys.ts#L80)

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`](#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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/positionKeys.ts#L50)

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`](#coordinatepairkey)

##### position

> `readonly` **position**: [`CoordinatePairKey`](#coordinatepairkey)

***

### coordinatePairKey()

> **coordinatePairKey**(`first`, `second`): [`CoordinatePairKey`](#coordinatepairkey)

Defined in: [packages/prismarine/src/world/positionKeys.ts:26](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/positionKeys.ts#L26)

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`](#coordinatepairkey)

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