hytopia
Version:
The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.
156 lines (73 loc) • 2.73 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [server](./server.md) > [BlockTextureRegistry](./server.blocktextureregistry.md)
## BlockTextureRegistry class
Manages block textures and block texture atlas generation of the game.
When to use: querying texture atlas UVs and transparency hints for blocks. Do NOT use for: runtime texture modifications; regenerate atlas offline in dev.
**Signature:**
```typescript
export default class BlockTextureRegistry
```
## Remarks
The BlockTextureRegistry is created internally as a global singleton accessible via `BlockTextureRegistry.instance`<!-- -->. The atlas is preloaded during server startup and cached in memory.
Pattern: call `BlockTextureRegistry.hasBlockTexture` before lookup to avoid warnings. Anti-pattern: assuming missing textures are silently ignored.
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `BlockTextureRegistry` class.
## Example
```typescript
import { BlockTextureRegistry } from 'hytopia';
const blockTextureRegistry = BlockTextureRegistry.instance;
const metadata = blockTextureRegistry.getBlockTextureMetadata('blocks/stone.png');
```
\*\*Category:\*\* Textures
## Properties
<table><thead><tr><th>
Property
</th><th>
Modifiers
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[generate](./server.blocktextureregistry.generate.md)
</td><td>
</td><td>
boolean
</td><td>
Whether to generate the atlas if needed.
Defaults to `true` in development, `false` in production.
\*\*Category:\*\* Textures
</td></tr>
<tr><td>
[instance](./server.blocktextureregistry.instance.md)
</td><td>
`static`
`readonly`
</td><td>
[BlockTextureRegistry](./server.blocktextureregistry.md)
</td><td>
The global BlockTextureRegistry instance as a singleton.
\*\*Category:\*\* Textures
</td></tr>
</tbody></table>
## Methods
<table><thead><tr><th>
Method
</th><th>
Modifiers
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[getBlockTextureMetadata(textureUri)](./server.blocktextureregistry.getblocktexturemetadata.md)
</td><td>
</td><td>
Retrieves metadata for a block texture. Returns array for cubemaps (6 faces) or standard textures (1 face).
</td></tr>
<tr><td>
[hasBlockTexture(textureUri)](./server.blocktextureregistry.hasblocktexture.md)
</td><td>
</td><td>
Checks if a block texture is registered in the atlas.
</td></tr>
</tbody></table>