Contributing
Adding a hook point
-
Find the choke point. This is the one function every path to the step goes through. A hook on one caller of a step that has three callers is a hook a plugin cannot rely on.
-
Declare the input and output with
rustmc_plugin::record!next to the call site. Choose an input a prepend can usefully rewrite, and an output the caller actually uses. An append that changes something nobody reads changes nothing. -
Wrap the step:
let output = crate::plugins::hook(shared, "family.point", input, |input| { the_games_own_step(input) });The name must be a string literal so
tools/api_check.pycan find it. A family whose names are computed (command.*,packet.*) is derived by the checker from its own data instead. -
Prove it. Add one line to a catalogue file under
crates/rustmc-server/src/api_tests/catalogue/:crate::api_tests!(family_point, Case::new("family.point", fresh, observe, reply));observemust run the step through the server's own call site and read back what a client or the world would see.replygives, for each mode, an answer that changes it. -
Document it in the family's page under
docs/api/reference/hooks/, and regenerate the index withpython tools/gen_api_docs.py. -
Check:
python tools/api_check.py.
From docs/api/contributing/adding-a-hook-point.md in the RustMC repository at bbd81209ad.