Class MaterialRegistry

Registry mapping material ids to Material descriptions.

Air (id 0) is implicit and is never registered. Registered ids must be integers in the range 1..255 so they fit in the one-byte cells of a ChunkedBitmap.

Constructors

Methods

Constructors

Methods

  • Looks up a material by id. Returns undefined for unknown ids and for id 0 (air is implicit).

    Parameters

    • id: number

    Returns undefined | Material

  • Looks up a material by id, throwing if it is not registered.

    Parameters

    • id: number

    Returns Material

    If id is not registered. Air (id 0) always throws because air has no material entry.

  • Registers a material so it can be sampled, rendered, and used by carve and deposit operations.

    Per-cell timer thresholds (burnDuration for fire materials, settleAfterTicks for materials with a settlesTo promotion target) must be integers in 1..256 because the underlying timer is a Uint8Array that saturates at 255 — a threshold above 256 means the counter current + 1 (max 256) never reaches the threshold, so the cell silently never burns out / never promotes. The check at registration prevents that footgun. See docs-dev/04-tuning-research.md.

    Parameters

    Returns void

    If material.id is not an integer in 1..255, or if a material with the same id is already registered. Also throws if burnDuration (for simulation: 'fire') or settleAfterTicks (when settlesTo is set) is outside 1..256.