Skip to content

Latest commit

 

History

History
224 lines (105 loc) · 2.93 KB

File metadata and controls

224 lines (105 loc) · 2.93 KB

Home > server > BlockType

BlockType class

Represents a block type.

Signature:

export default class BlockType extends EventRouter implements protocol.Serializable 

Extends: EventRouter

Implements: protocol.Serializable

Remarks

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.

Events

This class is an EventRouter, and instances of it emit events with payloads listed under BlockTypeEventPayloads

Example

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);

Constructors

Constructor

Modifiers

Description

(constructor)(options)

Creates a new block type instance.

Properties

Property

Modifiers

Type

Description

colliderOptions

readonly

TrimeshColliderOptions

The collider options for the block type.

id

readonly

number

The unique identifier for the block type.

isLiquid

readonly

boolean

Whether the block type is a liquid.

isMeshable

readonly

boolean

Whether the block type is meshable.

name

readonly

string

The name of the block type.

textureUri

readonly

string

The URI of the texture for the block type.