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.
Note:packet_send and packet_receive fire on network threads — don't use
rendering or projection inside them.
Event
Fields
Notes
packet_send
name, decoded fields
cancellable
packet_receive
name, decoded fields
cancellable
packet_process
—
received packets are applied to the world
movement_packets
—
after movement packets are sent
player_packets
—
after 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)