Represents a block type.
Signature:
export default class BlockType extends EventRouter implements protocol.Serializable Extends: EventRouter
Implements: protocol.Serializable
Block types are created directly as instances. They support a variety of configuration options through the BlockTypeOptions constructor argument. Block types are registered with a BlockTypeRegistry instance, allowing you to create custom blocks with unique visual representations and behaviors.
This class is an EventRouter, and instances of it emit events with payloads listed under BlockTypeEventPayloads
const stoneBlockTypeId = 10;
world.blockTypeRegistry.registerBlockType(stoneBlockTypeId, new BlockType({
id: stoneBlockTypeId,
textureUri: 'textures/stone.png',
name: 'Stone',
}));
// Create a stone block at coordinate 0, 1, 0
world.chunkLattice.setBlock({ x: 0, y: 1, z: 0 }, stoneBlockTypeId);|
Constructor |
Modifiers |
Description |
|---|---|---|
|
Creates a new block type instance. |
|
Property |
Modifiers |
Type |
Description |
|---|---|---|---|
|
|
The collider options for the block type. | ||
|
|
number |
The unique identifier for the block type. | |
|
|
boolean |
Whether the block type is a liquid. | |
|
|
boolean |
Whether the block type is meshable. | |
|
|
string |
The name of the block type. | |
|
|
string |
The URI of the texture for the block type. |