Using an AI agent
This page is written for a coding agent, and for a person who points one at it: "Read https://playsunrise.net/docs/modding/for-agents and make me a Sunrise native mod". It holds the exact commands and the rules that decide whether the code compiles. The same material, with the explanations, is in Install the mod tool and Your first native mod.
From Sunrise's modding book716c272
Facts
- Sunrise is Minecraft: Java Edition 26.3 written in Rust. A mod is one
.smodpackage: asunrise-mod.tomlmanifest,assets/,data/and, for a code mod, a Rust crate that uses thesunrise-mod-apicrate (library namemod_api). - A native mod is compiled against the exact game build it pins. The pin is written by the tool.
- The tool is
cargo sunrise-mod. If it printsno such command: sunrise-mod, it is not installed: do step 1. - Do not guess a hook's name, an event's fields or a host method. Look them up (see "Finding the API").
1. Install the tool
Take the page Install the mod tool and run the block for the user's computer. It reads the current Nightly's build, downloads that SDK release's tool, checks Sunrise's signature and the tool's hash, and puts cargo-sunrise-mod on the PATH. That page also covers choosing between the Nightly tool and the rolling mod-tool release, checking cargo sunrise-mod --version, and building from source on platforms where the prebuilt binary does not run.
2. Make and check a native mod
cargo sunrise-mod new greeter --template native
cd greeter
cargo sunrise-mod checknew writes a complete project and fetches its SDK into .sunrise/sdk/. check compiles it for the project's own target (this computer for a native mod). For a native mod, check prints the mod's name and the pinned build, and either summarizes API usage or says that the mod is made for one build and has no uses table. Run check after every edit, and fix what it reports before going on. Use another mod id by changing the folder name: new turns it into the id.
To compile it against the prebuilt game, run cargo sunrise-mod build: it fetches the pinned SDK's compiled slices into a per-user cache and installs the Rust the SDK names with rustup, so it needs the network the first time. To play it, run cargo sunrise-mod run --resources <folder> -- <game args>; the user has to make those prepared resources from their own Minecraft (Prepared resources), so ask for the folder and never download Mojang's files. For [[jar]] originals, add the developer's local jar with cargo sunrise-mod use-jar <path> before running. Run cargo test for the logic the hooks use. A build server uses the plan contract in Your first native mod.
Rules that matter
- The crate root,
src/lib.rs, holds exactly oneimpl Hooks for <Type>marked#[mod_api::sunrise_mod]. The type implementsDefault. Write only the hook methods the mod needs, inside that block: the macro subscribes the mod to the methods it sees written. Never write ahooks()factory yourself. A marked impl in a submodule fails with "cannot find functionhooks". - Import from
mod_apionly. A native mod never depends on the game's own crates. sunrise-mod.tomlis generated bynewand is the only source of the mod's id, version and pins. Never write it from nothing and never write a commit into it by hand. To change what it declares (name, description, dependencies) edit that one field in the generated file. To move to a newer game build runcargo sunrise-mod pin.- Ids are
[a-z0-9_], at most 64 characters. A code mod declares[native]. Unknown manifest fields are refused. - Hook names follow NeoForge 26.3. An event is
&mut. A write to the world needs aServerHost; a client hook gets aClientHost, so the wrong side does not compile. - Leave
apiandcapabilitiesout of the source manifest;buildadds them to the packed.smodmanifest. A native build also records the mixins revision it used. Normally omitnative.mixinsfrom the source manifest; see The pin for explicit pins. - Extra crates.io dependencies are allowed and are pinned by the mod's own
Cargo.lock; a git or path dependency outside the mod is refused. Thesunrise-mod-apipath inCargo.tomlpoints at.sunrise/sdk/and stays as written. - Do not commit
.sunrise/(the template's.gitignorealready skips it). - Run
cargo sunrise-mod checkbefore saying the work is done, and show its output.cargo sunrise-mod check <file.smod>is for a released package with its attestation.
Finding the API
Read the book's pages directly for the task you're working on.
cargo sunrise-mod hooks <words>searches the pinned build's hooks offline, by id, doc and counterpart name; every word must match.- The mod API reference is the rustdoc of
mod_api: start atHooks,Host,ServerHostandClientHost. Build it from a Sunrise checkout withcargo doc -p sunrise-mod-api --no-deps --open. - Writing hooks gives the crate's shape, Hooks and the Host the model, Parts per-object behaviour and Attachments per-object data.
- Hook notes and NeoForge counterparts say what each hook does and which NeoForge event it matches.
- The manifest and the package lists every manifest field.
Edit this page on GitHub · Spotted something wrong? Open an issue or ask on Discord.



