Events

Subscribe with module:event(name, fn). The callback receives one table with the event's fields (or nothing if the event has none). Names ignore case and underscores: render_2d == render2d == Render_2D.

Cancellable events have a :cancel() method — call it to stop the event:

module:event("chat", function(e)
    if e.text:find("spam") then e:cancel() end
end)

Writable fields are read back after your callback — assign a new value and the game uses it:

module:event("input", function(e)
    e.jump = true          -- player movement is controlled through input
end)

Callbacks only run while the module is enabled. The event table is only valid inside the callback — don't store it for later.

Ticks

EventFieldsNotes
tickbefore the player tick; cancellable
post_tickafter the player tick
pre_interactionbefore attacks and item use are processed

Input

EventFieldsNotes
inputforward, backward, left, right, jump, sneak, sprint — all writablecancellable; the way to control player movement
keykey, action, modscancellable; GLFW key codes
charchar, codepoint, modscancellable; a typed character
mouse_movex, ycancellable
mouse_scrollhorizontal, verticalcancellable
mouse_lookdelta_x, delta_ycancellable; camera rotation by mouse
cursor_lockstate = "lock" / "unlock"cancellable
slot_dragslot, button, shiftcancellable; dragging across container slots

Chat & text

EventFieldsNotes
chattextcancellable; a message arrived in chat
chat_sendtextcancellable; you are about to send a message
titletext, kind = "title"/"subtitle"/"actionbar"a title appeared on screen
boss_bartextthe boss bar text changed

Combat & interaction

EventFieldsNotes
attacktargetentity tablecancellable; before you hit
post_attacktargetafter the hit
item_usecooldown — writablecancellable
block_interacthand, x, y, z, sidecancellable; hand = "main"/"off"
block_placehand, x, y, z, side, itemitem is an item table
block_breakingstate = "start"/"stop", block, x, y, z

Movement

EventFieldsNotes
jumpyaw, cooldown — writablecancellable
landx, y, z, fall_distanceyou touched the ground
slowdownmultiplier — writablecancellable; slowdown while using an item

Network

Note: packet_send and packet_receive fire on network threads — don't use rendering or projection inside them.

EventFieldsNotes
packet_sendname, decoded fieldscancellable
packet_receivename, decoded fieldscancellable
packet_processreceived packets are applied to the world
movement_packetsafter movement packets are sent
player_packetsafter player packets are sent

name is the mod's own stable snake_case packet name — the same one packets.send accepts (Minecraft class names are obfuscated at runtime, so packets are never matched by class name). Common packets also carry decoded payload fields; the full list is on the Packets page.

module:event("packet_receive", function(e)
    if e.name == "entity_velocity" and e.entity_id == local_player.entity().id then
        e:cancel()  -- ignore knockback
    end
end)

World & modules

EventFields
chunk_loadx, z
chunk_unloadx, z
module_statemodule — module name, enabled

Rendering

render_2d, render_gui and render_3d receive a canvas / renderer object instead of a field table.

EventFieldsNotes
frameevery frame
render_2d2D canvasdraw over the game (HUD)
render_gui2D canvasdraw during GUI screens
render_3d3D rendererdraw in the world
camera_ratioshrink — writable
sky_colorcolor — writable, original
time_of_daytime — writable, originalvisual time of day
skyboxrendered — writable (true hides the vanilla sky)
fogred, green, blue, alpha, environmental_start, environmental_end, render_distance_start, render_distance_end — all writablecolor channels are 0..1
window_resizewidth, height