Skip to main content

IDRegistry

Module used to manage item and block IDs. Items and blocks have the same underlying nature, so their IDs are interchangeable. Though, the blocks are defined "twice", as an item (in player's hand or inventory) and as a tile (a block placed in the world).

Index

Variables

constBLOCK_ID_OFFSET

BLOCK_ID_OFFSET: number

Defines the numeric ID of the first user-defined block.

constITEM_ID_OFFSET

ITEM_ID_OFFSET: number

Defines the numeric ID of the first user-defined item.

constMAX_ID

MAX_ID: number

Defines maximum item/block ID.

Functions

ensureBlockId

  • ensureBlockId(id: number): number
  • Ensures given ID is a tile ID, not a block ID. It is generally recommended to use Block.convertItemToBlockId since it performs less calculations.


    Parameters

    • id: number

      block or tile ID

    Returns number

    Tile ID.

ensureItemId

  • ensureItemId(id: number): number
  • Ensures given ID is a block ID, not a tile ID. It is generally recommended to use Block.convertBlockToItemId since it performs less calculations.


    Parameters

    • id: number

      block or tile ID

    Returns number

    Block ID.

genBlockID

  • genBlockID(name: string): number
  • Generates a new numeric block ID. Used in Block module functions and in some other block-related functions.


    Parameters

    • name: string

      string block ID; Inner Core converts it to block_<name> as minecraft vanilla block ID to avoid string ID clashes (since 3.1.0b126 support namespaces, should be namespace:snake_case)

    Returns number

    Numeric block ID.

genItemID

  • genItemID(name: string): number
  • Generates a new numeric item ID. Used in