Contributing

Adding a hook point

  1. 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.

  2. 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.

  3. 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.py can find it. A family whose names are computed (command.*, packet.*) is derived by the checker from its own data instead.

  4. 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));
    

    observe must run the step through the server's own call site and read back what a client or the world would see. reply gives, for each mode, an answer that changes it.

  5. Document it in the family's page under docs/api/reference/hooks/, and regenerate the index with python tools/gen_api_docs.py.

  6. Check: python tools/api_check.py.

From docs/api/contributing/adding-a-hook-point.md in the RustMC repository at bbd81209ad.