hytopia
Version:
The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.
68 lines (34 loc) • 1.49 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [server](./server.md) > [ChunkLattice](./server.chunklattice.md) > [initializeBlocks](./server.chunklattice.initializeblocks.md)
## ChunkLattice.initializeBlocks() method
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`<!-- -->.
**Signature:**
```typescript
initializeBlocks(blocks: {
[blockTypeId: number]: BlockPlacement[];
}): void;
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
blocks
</td><td>
{ \[blockTypeId: number\]: [BlockPlacement](./server.blockplacement.md)<!-- -->\[\]; }
</td><td>
The blocks to initialize, keyed by block type ID.
\*\*Side effects:\*\* Clears existing data, creates colliders, and emits `ChunkLatticeEvent.SET_BLOCK` per block.
\*\*Category:\*\* Blocks
</td></tr>
</tbody></table>
**Returns:**
void
## Remarks
\*\*Clears first:\*\* Calls `ChunkLattice.clear` before initializing, removing all existing blocks and colliders.
\*\*Collider optimization:\*\* Creates one collider per block type with all placements combined. Voxel colliders have their states combined for efficient neighbor collision detection.