Skip to content

Behaviour overrides and value events

Status: Partly implemented. Behaviour tables for your own blocks and items (cl_block_desc.behavior: use_without_item, attack, random_tick; cl_item_desc.behavior: use) and the mutable fields of action events work. Overrides of vanilla content’s behaviour and value events are Planned; mixins cover part of that today.

Concepts and examples: Events, behaviours and mixins. Mixins: Mixins.

Behaviour tables (your own content)

Table Entry Signature Page
cl_block_behavior use_without_item cl_override (const cl_block_ctx*, cl_entity player, cl_hand, cl_interaction_result* out) Blocks and block states
attack cl_override (const cl_block_ctx*, cl_entity player, int32_t* unused)
random_tick cl_override (const cl_block_ctx*, int32_t* unused)
cl_item_behavior use cl_override (const cl_item_ctx*, cl_interaction_result* out) Items and item stacks

Return CL_OVERRIDE_HANDLED (with *out set) or CL_OVERRIDE_CALL_ORIGINAL. C++ takes lambdas (clight::registry::block(desc, {.use_without_item = ...})), Lua takes functions in a behavior table.

Mutable event fields (the value-event subset that exists)

Event Mutable field
block.break xp, drop_items
entity.damage amount
player.chat message
player.command command
client.chat_received, client.chat_send message
client.sound_play volume, pitch
-- half damage from falling
cl.on("entity.damage", function(event)
  if event.source == "minecraft:fall" then event.amount = event.amount / 2 end
end)

Planned

  • Overrides of any block, item, entity type or effect, including vanilla’s, as a priority-ordered chain that ends at vanilla’s behaviour, with many more entries (placement, can_survive, neighbour updates, entity contact, redstone, mining speed, tooltips).
  • Value events: payloads whose result starts as the vanilla value (fall damage, knockback, mining speed, reach, FOV, fog), listed in Value event list.