Skip to content

Registries (function list)

Status: Implemented (API 1.24). Generated from client/clight/idl/clight_api.json by tools/docs/gen_api_reference.py; do not edit by hand. 24 functions, the newest from API 1.11.

Explanations and examples: Registries, Blocks, Items. Every function of the registry module is listed here in table order. The details of each function follow the table, in the same order. Side: where the function works (server, client, both). Context: the thread it may be called on (Conventions). Since: the API version that added it.

C function Lua Side Context Since
cl_block_register cl.registry.block_register both MAIN 1.0
cl_item_register cl.registry.item_register both MAIN 1.0
cl_holder_value cl.registry.holder_value both ANY 1.0
cl_block_lookup cl.registry.block_lookup both ANY 1.0
cl_item_lookup cl.registry.item_lookup both ANY 1.0
cl_block_name cl.registry.block_name both ANY 1.0
cl_item_name cl.registry.item_name both ANY 1.0
cl_block_default_state cl.registry.block_default_state both ANY 1.0
cl_block_state_block cl.registry.block_state_block both ANY 1.0
cl_block_state_is cl.registry.block_state_is both ANY 1.0
cl_registries_frozen cl.registry.registries_frozen both ANY 1.0
cl_entity_type_register cl.registry.entity_type_register both MAIN 1.8
cl_entity_type_fallback cl.registry.entity_type_fallback both ANY 1.8
cl_damage_type_register cl.registry.damage_type_register both MAIN 1.10
cl_spawn_rule_register cl.registry.spawn_rule_register server MAIN 1.10
cl_block_state_property cl.registry.block_state_property both ANY 1.11
cl_block_state_with cl.registry.block_state_with both ANY 1.11
cl_block_state_properties cl.registry.block_state_properties both ANY 1.11
cl_block_state_property_values cl.registry.block_state_property_values both ANY 1.11
cl_block_state_to_string cl.registry.block_state_to_string both ANY 1.11
cl_block_state_parse cl.registry.block_state_parse both ANY 1.11
cl_block_get_info cl.registry.block_get_info both ANY 1.11
cl_block_sound_type cl.registry.block_sound_type both ANY 1.11
cl_block_sound_event cl.registry.block_sound_event both ANY 1.11

cl_block_register

cl_result cl_block_register(const cl_block_desc* desc, cl_holder* out);
  • Side: both. Context: MAIN (startup (main thread)). Since: API 1.0.
  • Lua: cl.registry.block_register
  • C++: clight::registry::block_register(const cl_block_desc* desc) → Expected<cl_holder>
  • The last parameter receives the result. Lua returns it; C++ returns it in Expected<T>.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_item_register

cl_result cl_item_register(const cl_item_desc* desc, cl_holder* out);
  • Side: both. Context: MAIN (startup (main thread)). Since: API 1.0.
  • Lua: cl.registry.item_register
  • C++: clight::registry::item_register(const cl_item_desc* desc) → Expected<cl_holder>
  • The last parameter receives the result. Lua returns it; C++ returns it in Expected<T>.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_holder_value

uint32_t cl_holder_value(cl_holder h);

Raw registry id behind a holder (valid after lifecycle.registries_frozen; 0xFFFFFFFF before).

  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.registry.holder_value
  • C++: clight::registry::holder_value(cl_holder h) → uint32_t

cl_block_lookup

cl_result cl_block_lookup(cl_str id, cl_block_id* out);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.registry.block_lookup
  • C++: clight::registry::block_lookup(std::string_view id) → Expected<cl_block_id>
  • The last parameter receives the result. Lua returns it; C++ returns it in Expected<T>.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_item_lookup

cl_result cl_item_lookup(cl_str id, cl_item_id* out);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.registry.item_lookup
  • C++: clight::registry::item_lookup(std::string_view id) → Expected<cl_item_id>
  • The last parameter receives the result. Lua returns it; C++ returns it in Expected<T>.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_block_name

cl_result cl_block_name(cl_block_id block, char* buf, size_t cap, size_t* out_len);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.registry.block_name
  • C++: clight::registry::block_name(cl_block_id block) → Expected<std::string>
  • Writes a string: buf / cap / out_len (a too small buffer returns CL_E_BUFFER_TOO_SMALL with the needed length in *out_len). Lua and C++ return the string.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_item_name

cl_result cl_item_name(cl_item_id item, char* buf, size_t cap, size_t* out_len);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.registry.item_name
  • C++: clight::registry::item_name(cl_item_id item) → Expected<std::string>
  • Writes a string: buf / cap / out_len (a too small buffer returns CL_E_BUFFER_TOO_SMALL with the needed length in *out_len). Lua and C++ return the string.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_block_default_state

cl_block_state cl_block_default_state(cl_block_id block);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.registry.block_default_state
  • C++: clight::registry::block_default_state(cl_block_id block) → cl_block_state

cl_block_state_block

cl_block_id cl_block_state_block(cl_block_state state);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.registry.block_state_block
  • C++: clight::registry::block_state_block(cl_block_state state) → cl_block_id

cl_block_state_is

bool cl_block_state_is(cl_block_state state, cl_str block);

“minecraft:stone” -> true when the state belongs to that block.

  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.registry.block_state_is
  • C++: clight::registry::block_state_is(cl_block_state state, std::string_view block) → bool

cl_registries_frozen

bool cl_registries_frozen(void);
  • Side: both. Context: ANY (any thread). Since: API 1.0.
  • Lua: cl.registry.registries_frozen
  • C++: clight::registry::registries_frozen() → bool

cl_entity_type_register

cl_result cl_entity_type_register(const cl_entity_type_desc* desc, cl_holder* out);

Registers a custom entity type (lifecycle.register; Lua: cl.entities.register{…}).

  • Side: both. Context: MAIN (startup (main thread)). Since: API 1.8.
  • Lua: cl.registry.entity_type_register
  • C++: clight::registry::entity_type_register(const cl_entity_type_desc* desc) → Expected<cl_holder>
  • The last parameter receives the result. Lua returns it; C++ returns it in Expected<T>.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_entity_type_fallback

cl_result cl_entity_type_fallback(cl_str id, char* buf, size_t cap, size_t* out_len);

The vanilla type other clients see for an entity type id (a vanilla id: itself). CL_E_NOT_FOUND: unknown type.

  • Side: both. Context: ANY (any thread). Since: API 1.8.
  • Lua: cl.registry.entity_type_fallback
  • C++: clight::registry::entity_type_fallback(std::string_view id) → Expected<std::string>
  • Writes a string: buf / cap / out_len (a too small buffer returns CL_E_BUFFER_TOO_SMALL with the needed length in *out_len). Lua and C++ return the string.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_damage_type_register

cl_result cl_damage_type_register(const cl_damage_type_desc* desc, cl_holder* out);

Registers a damage type (lifecycle.register; Lua: cl.registry.damage_type_register{…} or cl.damage_types.register).

  • Side: both. Context: MAIN (startup (main thread)). Since: API 1.10.
  • Lua: cl.registry.damage_type_register
  • C++: clight::registry::damage_type_register(const cl_damage_type_desc* desc) → Expected<cl_holder>
  • The last parameter receives the result. Lua returns it; C++ returns it in Expected<T>.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_spawn_rule_register

cl_result cl_spawn_rule_register(const cl_spawn_rule_desc* desc);

Adds a natural spawn rule (lifecycle.register or before the server starts; Lua: cl.registry.spawn_rule{…}).

  • Side: server. Context: MAIN (startup (main thread)). Since: API 1.10.
  • Lua: cl.registry.spawn_rule_register
  • C++: clight::registry::spawn_rule_register(const cl_spawn_rule_desc* desc) → Expected<void>
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_block_state_property

cl_result cl_block_state_property(cl_block_state state, cl_str name, char* buf, size_t cap, size_t* out_len);

A block property’s value as text (“open” -> “true”, “facing” -> “north”, “age” -> “3”). CL_E_NOT_FOUND: the state’s block has no such property (mod blocks have none).

  • Side: both. Context: ANY (any thread). Since: API 1.11.
  • Lua: cl.registry.block_state_property
  • C++: clight::registry::block_state_property(cl_block_state state, std::string_view name) → Expected<std::string>
  • Writes a string: buf / cap / out_len (a too small buffer returns CL_E_BUFFER_TOO_SMALL with the needed length in *out_len). Lua and C++ return the string.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_block_state_with

cl_result cl_block_state_with(cl_block_state state, cl_str name, cl_str value, cl_block_state* out);

The state of the same block with one property changed (StateHolder#setValue). value: one of the property’s values as text (“true”, “east”, “3”). CL_E_NOT_FOUND: no such property; CL_E_INVALID_ARGUMENT: not one of its values.

  • Side: both. Context: ANY (any thread). Since: API 1.11.
  • Lua: cl.registry.block_state_with
  • C++: clight::registry::block_state_with(cl_block_state state, std::string_view name, std::string_view value) → Expected<cl_block_state>
  • The last parameter receives the result. Lua returns it; C++ returns it in Expected<T>.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_block_state_properties

cl_result cl_block_state_properties(cl_block_state state, char* buf, size_t cap, size_t* out_len);

The block’s properties, comma-separated in their vanilla order (“facing,half,hinge,open,powered”).

  • Side: both. Context: ANY (any thread). Since: API 1.11.
  • Lua: cl.registry.block_state_properties
  • C++: clight::registry::block_state_properties(cl_block_state state) → Expected<std::string>
  • Writes a string: buf / cap / out_len (a too small buffer returns CL_E_BUFFER_TOO_SMALL with the needed length in *out_len). Lua and C++ return the string.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_block_state_property_values

cl_result cl_block_state_property_values(cl_block_state state, cl_str name, char* buf, size_t cap, size_t* out_len);

A property’s values in order, comma-separated (“north,south,west,east”).

  • Side: both. Context: ANY (any thread). Since: API 1.11.
  • Lua: cl.registry.block_state_property_values
  • C++: clight::registry::block_state_property_values(cl_block_state state, std::string_view name) → Expected<std::string>
  • Writes a string: buf / cap / out_len (a too small buffer returns CL_E_BUFFER_TOO_SMALL with the needed length in *out_len). Lua and C++ return the string.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_block_state_to_string

cl_result cl_block_state_to_string(cl_block_state state, char* buf, size_t cap, size_t* out_len);

“minecraft:oak_door[facing=north,half=lower,hinge=left,open=false,powered=false]” (the /setblock syntax).

  • Side: both. Context: ANY (any thread). Since: API 1.11.
  • Lua: cl.registry.block_state_to_string
  • C++: clight::registry::block_state_to_string(cl_block_state state) → Expected<std::string>
  • Writes a string: buf / cap / out_len (a too small buffer returns CL_E_BUFFER_TOO_SMALL with the needed length in *out_len). Lua and C++ return the string.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_block_state_parse

cl_result cl_block_state_parse(cl_str text, cl_block_state* out);

Parses the /setblock syntax (“minecraft:oak_stairs[facing=east]”; missing properties keep the default).

  • Side: both. Context: ANY (any thread). Since: API 1.11.
  • Lua: cl.registry.block_state_parse
  • C++: clight::registry::block_state_parse(std::string_view text) → Expected<cl_block_state>
  • The last parameter receives the result. Lua returns it; C++ returns it in Expected<T>.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_block_get_info

cl_result cl_block_get_info(cl_block_state state, cl_block_info* out);
  • Side: both. Context: ANY (any thread). Since: API 1.11.
  • Lua: cl.registry.block_get_info
  • C++: clight::registry::block_get_info(cl_block_state state) → Expected<cl_block_info>
  • The last parameter receives the result. Lua returns it; C++ returns it in Expected<T>.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_block_sound_type

cl_result cl_block_sound_type(cl_block_state state, char* buf, size_t cap, size_t* out_len);

The block’s SoundType as a name: the group of its sound events (“stone”, “wood”, “grass”, “gravel”, “metal”, “glass”, “wool”, “sand”, “snow”, “amethyst_block”, …; block.<name>.break). For footstep, acoustics and particle mods.

  • Side: both. Context: ANY (any thread). Since: API 1.11.
  • Lua: cl.registry.block_sound_type
  • C++: clight::registry::block_sound_type(cl_block_state state) → Expected<std::string>
  • Writes a string: buf / cap / out_len (a too small buffer returns CL_E_BUFFER_TOO_SMALL with the needed length in *out_len). Lua and C++ return the string.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.

cl_block_sound_event

cl_result cl_block_sound_event(cl_block_state state, cl_block_sound kind, char* buf, size_t cap, size_t* out_len);

The sound event of one of the block’s sounds (“minecraft:block.stone.break”).

  • Side: both. Context: ANY (any thread). Since: API 1.11.
  • Lua: cl.registry.block_sound_event
  • C++: clight::registry::block_sound_event(cl_block_state state, cl_block_sound kind) → Expected<std::string>
  • Writes a string: buf / cap / out_len (a too small buffer returns CL_E_BUFFER_TOO_SMALL with the needed length in *out_len). Lua and C++ return the string.
  • Returns CL_OK or an error code (Error codes). Lua raises a cl.Error on failure.