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,40 @@
# Incari's Weather Changer (features/weatherchanger) 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_weatherchanger"
version = "0.1.0"
priority = 100
[[module]]
id = "runtime"
file = "crates/horizon-client/src/game.rs"
name = "incari_weatherchanger"
source = "runtime.rs"
[[injection]]
id = "weather"
# Horizon's seen_weather hook point is still a pending fragment
# (tools/native-hook-fragments/incari_client_hooks.json), so this targets its function. Make it
# `hook = "seen_weather"` and `hook_version = 1` once Horizon stamps it.
target = "horizon_client::game::native_hooks::Game<'_>::native_seen_weather"
kind = "HEAD"
helper = "weather.rs"
bindings = [
{ name = "game", ty = "&crate::game::Game<'_>", value = "self" },
{ name = "rain", ty = "&mut f32", value = "&mut *rain" },
{ name = "thunder", ty = "&mut f32", value = "&mut *thunder" },
]
[[injection]]
id = "time"
# Horizon's seen_day_time hook point is still a pending fragment
# (tools/native-hook-fragments/incari_client_hooks.json), so this targets its function. Make it
# `hook = "seen_day_time"` and `hook_version = 1` once Horizon stamps it.
target = "horizon_client::game::native_hooks::Game<'_>::native_seen_day_time"
kind = "HEAD"
helper = "time.rs"
bindings = [
{ name = "game", ty = "&crate::game::Game<'_>", value = "self" },
{ name = "day_time", ty = "&mut i64", value = "&mut *day_time" },
]
@@ -0,0 +1,45 @@
// Incari's Weather Changer for the Rust build (ADR 0068, 0069), as features/weatherchanger does
// it: the weather and time of day on your screen only; the server's go on underneath. Its settings
// are the module's in `incari_core::modules` (the Java ids). Horizon snows only where the biome is
// cold, so Snow is rain's levels: snow there, rain elsewhere. No game types: rust/lib.rs tests it.
/// The module's id, as the Java client's profiles name it.
pub const ID: &str = "weatherchanger";
/// The rain and thunder levels for the `weather` setting's key, or none to keep the world's.
pub fn weather(weather: &str) -> Option<(f32, f32)> {
match weather {
"clear" => Some((0.0, 0.0)),
"rain" | "snow" => Some((1.0, 0.0)),
"thunder" => Some((1.0, 1.0)),
_ => None,
}
}
/// The day time showing `hour` o'clock on the day `day_time` is in, so the moon keeps its phase.
/// The game's day starts at 06:00 (Java's `ticks`).
pub fn held_time(day_time: i64, hour: i32) -> i64 {
let ticks = i64::from(hour - 6).rem_euclid(24) * 1000;
day_time - day_time.rem_euclid(24000) + ticks
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn sets_the_sky_by_choice() {
assert_eq!(weather("clear"), Some((0.0, 0.0)));
assert_eq!(weather("world"), None);
assert_eq!(weather("thunder"), Some((1.0, 1.0)));
assert_eq!(weather("snow"), Some((1.0, 0.0)));
}
#[test]
fn holds_the_hour_on_the_same_day() {
assert_eq!(held_time(0, 12), 6000);
assert_eq!(held_time(24000 * 3 + 500, 6), 72000);
assert_eq!(held_time(100, 0), 18000);
assert_eq!(held_time(-100, 12), -24000 + 6000);
}
}
@@ -0,0 +1,8 @@
// The time of day the player sees, while held.
fn incari_weatherchanger_time(game: &crate::game::Game<'_>, day_time: &mut i64) {
use crate::game::{incari_client as c, incari_weatherchanger as m};
let _ = game;
if let Some(hour) = c::settings(m::ID, |s| s.bool("hold-time").then(|| s.int("hour"))).flatten() {
*day_time = m::held_time(*day_time, hour);
}
}
@@ -0,0 +1,8 @@
// The weather the player sees.
fn incari_weatherchanger_weather(game: &crate::game::Game<'_>, rain: &mut f32, thunder: &mut f32) {
use crate::game::{incari_client as c, incari_weatherchanger as m};
let _ = game;
if let Some((r, t)) = c::settings(m::ID, |s| m::weather(s.choice("weather"))).flatten() {
(*rain, *thunder) = (r, t);
}
}