<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [server](./server.md) &gt; [ChunkLattice](./server.chunklattice.md)

## ChunkLattice class

A lattice of chunks that represent a world's terrain.

When to use: reading or mutating blocks in world space. Do NOT use for: per-entity placement logic; prefer higher-level game systems.

**Signature:**

```typescript
export default class ChunkLattice extends EventRouter 
```
**Extends:** [EventRouter](./server.eventrouter.md)

## Remarks

The lattice owns all chunks and keeps physics colliders in sync with blocks.

<h2>Coordinate System</h2>

- \*\*Global (world) coordinates:\*\* integer block positions in world space. - \*\*Chunk origin:\*\* world coordinate at the chunk's minimum corner (multiples of 16). - \*\*Local coordinates:\*\* 0..15 per axis within a chunk. - \*\*Axes:\*\* +X right, +Y up, -Z forward. - \*\*Origin:\*\* (0,0,0) is the world origin.

\*\*Category:\*\* Blocks

## Constructors

<table><thead><tr><th>

Constructor


</th><th>

Modifiers


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[(constructor)(world)](./server.chunklattice._constructor_.md)


</td><td>


</td><td>

Creates a new chunk lattice instance.


</td></tr>
</tbody></table>

## Properties

<table><thead><tr><th>

Property


</th><th>

Modifiers


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[chunkCount](./server.chunklattice.chunkcount.md)


</td><td>

`readonly`


</td><td>

number


</td><td>

The number of chunks in the lattice.

\*\*Category:\*\* Blocks


</td></tr>
</tbody></table>

## Methods

<table><thead><tr><th>

Method


</th><th>

Modifiers


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[clear()](./server.chunklattice.clear.md)


</td><td>


</td><td>

Removes and clears all chunks and their blocks from the lattice.

Use for: full world resets or map reloads. Do NOT use for: incremental changes; use `ChunkLattice.setBlock`<!-- -->.


</td></tr>
<tr><td>

[getAllChunks()](./server.chunklattice.getallchunks.md)


</td><td>


</td><td>

Gets all chunks in the lattice.


</td></tr>
<tr><td>

[getBlockId(globalCoordinate)](./server.chunklattice.getblockid.md)


</td><td>


</td><td>

Gets the block type ID at a specific global coordinate.


</td></tr>
<tr><td>

[getBlockType(globalCoordinate)](./server.chunklattice.getblocktype.md)


</td><td>


</td><td>

Gets the block type at a specific global coordinate.


</td></tr>
<tr><td>

[getBlockTypeCount(blockTypeId)](./server.chunklattice.getblocktypecount.md)


</td><td>


</td><td>

Gets the number of blocks of a specific block type in the lattice.


</td></tr>
<tr><td>

[getChunk(globalCoordinate)](./server.chunklattice.getchunk.md)


</td><td>


</td><td>

Gets the chunk that contains the given global coordinate.


</td></tr>
<tr><td>

[getOrCreateChunk(globalCoordinate)](./server.chunklattice.getorcreatechunk.md)


</td><td>


</td><td>

Gets the chunk for a given global coordinate, creating it if it doesn't exist.


</td></tr>
<tr><td>

[hasBlock(globalCoordinate)](./server.chunklattice.hasblock.md)


</td><td>


</td><td>

Checks if a block exists at a specific global coordinate.


</td></tr>
<tr><td>

[hasChunk(globalCoordinate)](./server.chunklattice.haschunk.md)


</td><td>


</td><td>

Checks if a chunk exists for a given global coordinate.


</td></tr>
<tr><td>

[initializeBlocks(blocks)](./server.chunklattice.initializeblocks.md)


</td><td>


</td><td>

Initializes all blocks in the lattice in bulk, replacing existing blocks.

Use for: loading maps or generating terrain in one pass. Do NOT use for: incremental edits; use `ChunkLattice.setBlock`<!-- -->.


</td></tr>
<tr><td>

[setBlock(globalCoordinate, blockTypeId, blockRotation)](./server.chunklattice.setblock.md)


</td><td>


</td><td>

Sets the block at a global coordinate by block type ID.

Use for: incremental terrain edits. Do NOT use for: bulk terrain loading; use `ChunkLattice.initializeBlocks`<!-- -->.


</td></tr>
</tbody></table>
