4.8 KiB
Porting a feature mod onto the Incari client (ADR 0069)
You're moving some of the Rust build's feature mods (rust/mods/<name>/) off Horizon's own
Options > Mods pages and onto Incari's own framework, so the Rust build looks and works exactly
like the Java client: settings in Incari's module menu with the Java ids, HUD elements placed by
anchor in Incari's HUD editor and drawn in Incari's Frost look.
What exists
rust/mods/incari/core/— crateincari_core(no game types): the framework, the look, the screens. Readsrc/modules.rs(every module's id, settings and HUD elements, exactly as the Java ones declare them),src/framework/setting.rs(Settings::bool/int/float/choice/color/keyby Java setting id;choicereturns the stored key, e.g."left"),src/hud.rs(HudCanvas:text,text_argb,fill(.., Tone),fill_argb,round,item,sprite,shape,color(tone)(honours the element's custom colour),text_element(text, widest, tone) -> [w, h]= Java's TextElement),src/theme.rs(Tone),src/input.rs(Key,Key::from_name).rust/mods/incari/glue.rs— modulecrate::game::incari_clientin the game, the helpers your hook files call:settings(module_id, |s: &Settings| ...) -> Option<R>: None while the module is off.on(module_id) -> bool.element(game: &Game, batch, module_id, element_id, |canvas| -> Option<[f32; 2]>): draws a HUD element at its own origin and scale (return its unscaled size, None to hide it) and puts it where the player placed it. Call it from thehudhook.canvas.moduleis the module's settings,canvas.elementthe element's,canvas.editingtrue in the HUD editor (show a sample when there's nothing to say, as Java's elements do).
- The template, already ported:
rust/mods/cps/(runtime.rs,hud.rs,horizon-mixin.toml). Compare it withgit diff HEAD -- rust/mods/cps/ the old version in git (git show HEAD:rust/mods/cps/...may not exist: the old files werelist.rs,settings.rs,click.rs, whichincari_glueused).
For each of your mods
- Read the Java module:
features/<name>/src/main/java/**andfeatures/<name>/README.md. That is the spec: same behaviour, same text, same defaults. Read the mod's current Rust files. - Delete
list.rs,settings.rs,click.rsand their[[injection]]s (mods,settings,settings_clickhooks) fromhorizon-mixin.toml. Keep every other hook the mod needs; add ones it needs to do what the Java module does, if Horizon has them (native-hooks.jsonin/home/bedrock/Documents/horizon-web-development, and the fork's pending fragments intools/native-hook-fragments/, targeted bytarget = "..."path asrust/mods/nohurtcamdoes). Don't edit the fork. runtime.rs(no game types, tested byrust/lib.rs): the module's logic, keyed by the Java setting ids/choice keys instead of the oldDef/Values/SETTINGStables. Remove its use ofsuper::incari(the old common module) unless something there is still truly needed. Keep it allocation-free on hot paths (thread-local caches like cps'swith_text).- Hook files: read settings with
crate::game::incari_client::settings(ID, |s| ...), draw HUD withcrate::game::incari_client::element(...)using the Java element ids and the Java drawing (text elements viatext_element; custom elements drawn with the canvas as the Javadraw(HudCanvas)does). Thecornersbinding of thehudhook is no longer used (let _ = corners;). Remove uses ofcrate::game::incari_glueandcrate::game::incari. - Keys a module binds itself (Zoom's key, Freelook's key...) are
keysettings: compare in thekeyhook withincari_core::input::Key::from_name(key). Toggle keys are handled by the client. - Update the mod's row in
rust/README.md's table ("Not here yet" column: what still differs from Java) — only your rows.
Checks
From /home/bedrock/Documents/incari-client/rust: cargo test and
cargo clippy --all-targets -- -D warnings must pass for the whole workspace (other agents are
editing other mods at the same time: if an error is in a mod that isn't yours, ignore it and say
so). You can't compile the game helpers (hud.rs etc.) here — only runtime.rs is compiled by
rust/lib.rs — so write them carefully against the signatures in glue.rs, the existing hook
signatures in each mod's horizon-mixin.toml, and the fork's native_hooks.rs. Don't run
./incari build or anything in work/ (another build may be running). Don't touch
rust/lib.rs, rust/mods/incari/, rust/mods/common/ or other mods. Don't commit.
Report: per mod, what now matches Java, what still differs and why, any hook point Horizon lacks
that the Java behaviour needs, and anything in glue.rs/incari_core you needed but wasn't there.