Archive incari-client (client, 26.3, clean)

This commit is contained in:
2026-11-28 00:54:38 -06:00
parent 7a6174687f
commit 12838e838c
2383 changed files with 280266 additions and 0 deletions
@@ -0,0 +1,12 @@
// Each frame: Old Textures and Programmer Art follow each other, as the Java module follows its pack.
fn incari_oldtextures_frame(game: &mut crate::game::Game<'_>) {
use crate::game::{incari_client as c, incari_oldtextures as m};
if !c::ready() {
return;
}
match m::follow(c::on(m::ID), game.native_programmer_art()) {
Some(m::Change::Pack(on)) => game.native_set_programmer_art(on),
Some(m::Change::Module(on)) => c::set_enabled(m::ID, on),
None => {}
}
}
@@ -0,0 +1,23 @@
# Incari's Old Textures (features/oldtextures) for the Rust build (ADR 0068, 0069). Hooks by name where Horizon
# has stamped the hook point (native-hooks.json), by function where it's still pending. Its
# settings are the client's (rust/mods/incari): the module menu shows them.
[mod]
id = "incari_oldtextures"
version = "0.1.0"
priority = 100
[[module]]
id = "runtime"
file = "crates/horizon-client/src/game.rs"
name = "incari_oldtextures"
source = "runtime.rs"
[[injection]]
id = "frame"
hook = "frame"
hook_version = 1
kind = "HEAD"
helper = "frame.rs"
bindings = [
{ name = "game", ty = "&mut crate::game::Game<'_>", value = "&mut *self" },
]
@@ -0,0 +1,79 @@
// Incari's Old Textures for the Rust build (ADR 0068, 0069), as features/oldtextures does it: the
// game's Programmer Art pack (pre-1.14 textures) is the module's switch (`follows_pack` in
// `incari_core::modules`). Turning the module on or off turns the pack with it; each change
// reloads resources. No game types: rust/lib.rs tests it.
/// The module's id, as the Java client's profiles name it.
pub const ID: &str = "oldtextures";
/// What changes, from the module's and the pack's state as last seen (`last`, none before the
/// first frame) and now: the module follows the pack at first and when the pack is switched in
/// Resource Packs; the pack follows the module when the module is turned on or off.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Change {
Pack(bool),
Module(bool),
}
pub fn change(last: Option<(bool, bool)>, on: bool, pack: bool) -> Option<Change> {
match last {
None if on != pack => Some(Change::Module(pack)),
Some((was, _)) if was != on && on != pack => Some(Change::Pack(on)),
Some((was, had)) if was == on && had != pack && on != pack => Some(Change::Module(pack)),
_ => None,
}
}
// The window's thread only: the frame hook runs there.
thread_local! {
static LAST: std::cell::Cell<Option<(bool, bool)>> = const { std::cell::Cell::new(None) };
}
/// Once a frame: what to change, if anything. The state seen is what it will be after it.
pub fn follow(on: bool, pack: bool) -> Option<Change> {
let c = change(LAST.get(), on, pack);
let after = match c {
Some(Change::Pack(p)) => (on, p),
Some(Change::Module(m)) => (m, pack),
None => (on, pack),
};
LAST.set(Some(after));
c
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn the_module_follows_the_pack_and_the_pack_the_module() {
assert_eq!(
change(None, false, true),
Some(Change::Module(true)),
"at first, the pack's state"
);
assert_eq!(change(None, true, true), None);
assert_eq!(
change(Some((false, false)), true, false),
Some(Change::Pack(true))
);
assert_eq!(
change(Some((true, true)), false, true),
Some(Change::Pack(false))
);
assert_eq!(
change(Some((false, false)), false, true),
Some(Change::Module(true)),
"switched in Resource Packs"
);
assert_eq!(change(Some((true, true)), true, true), None);
}
#[test]
fn follows_from_frame_to_frame() {
assert_eq!(follow(false, true), Some(Change::Module(true)));
assert_eq!(follow(true, true), None);
assert_eq!(follow(false, true), Some(Change::Pack(false)));
assert_eq!(follow(false, false), None);
}
}