UNPKG

hytopia

Version:

The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.

160 lines (76 loc) 2.49 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [server](./server.md) &gt; [BlockTypeRegistry](./server.blocktyperegistry.md) ## BlockTypeRegistry class Manages known block types in a world. **Signature:** ```typescript export default class BlockTypeRegistry extends EventRouter implements protocol.Serializable ``` **Extends:** [EventRouter](./server.eventrouter.md) **Implements:** protocol.Serializable ## Remarks Block type registries are created internally as a singleton for each [World](./server.world.md) instance in a game server. A block type registry allows you to register and retrieve block types by their unique id for a world. <h2>Events</h2> This class is an EventRouter, and instances of it emit events with payloads listed under [BlockTypeRegistryEventPayloads](./server.blocktyperegistryeventpayloads.md) The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `BlockTypeRegistry` class. ## Example ```typescript world.blockTypeRegistry.registerGenericBlockType({ id: 15, textureUri: 'textures/dirt.png', name: 'Dirt', }); ``` ## Properties <table><thead><tr><th> Property </th><th> Modifiers </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> [world](./server.blocktyperegistry.world.md) </td><td> `readonly` </td><td> [World](./server.world.md) </td><td> The world the block type registry is for. </td></tr> </tbody></table> ## Methods <table><thead><tr><th> Method </th><th> Modifiers </th><th> Description </th></tr></thead> <tbody><tr><td> [getAllBlockTypes()](./server.blocktyperegistry.getallblocktypes.md) </td><td> </td><td> Get all registered block types. </td></tr> <tr><td> [getBlockType(id)](./server.blocktyperegistry.getblocktype.md) </td><td> </td><td> Get a registered block type by its id. </td></tr> <tr><td> [registerBlockType(blockType)](./server.blocktyperegistry.registerblocktype.md) </td><td> </td><td> Register a block type. </td></tr> <tr><td> [registerGenericBlockType(blockTypeOptions)](./server.blocktyperegistry.registergenericblocktype.md) </td><td> </td><td> Register a generic block type. </td></tr> </tbody></table>