From b92a53e47cbed57d92d0c6a38f605dd8cec12ec9 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 20:37:52 +0100 Subject: [PATCH 01/15] Swing and pose the main arm of a left-handed mob --- .../examples/probe/entity_anim_fixture.rs | 1 + crates/horizon-client/src/mobs/anim.rs | 39 +++++++++----- crates/horizon-client/src/mobs/illager.rs | 11 ++-- crates/horizon-client/src/mobs/piglin.rs | 52 +++++++++++-------- 4 files changed, 67 insertions(+), 36 deletions(-) diff --git a/crates/horizon-client/examples/probe/entity_anim_fixture.rs b/crates/horizon-client/examples/probe/entity_anim_fixture.rs index 4aceb9f6f..4582033fe 100644 --- a/crates/horizon-client/examples/probe/entity_anim_fixture.rs +++ b/crates/horizon-client/examples/probe/entity_anim_fixture.rs @@ -592,6 +592,7 @@ pub fn main() -> horizon_client::Result<()> { pose, num("maxCrossbowChageDuration"), num("ticksUsingItem"), + false, ); } Species::Evoker | Species::Illusioner | Species::Pillager | Species::Vindicator => { diff --git a/crates/horizon-client/src/mobs/anim.rs b/crates/horizon-client/src/mobs/anim.rs index b81f224ae..c183aa59d 100644 --- a/crates/horizon-client/src/mobs/anim.rs +++ b/crates/horizon-client/src/mobs/anim.rs @@ -248,18 +248,24 @@ pub enum ArmPose { pub fn humanoid_pub(p: &mut Poses, s: &State, _m: &Mob) { humanoid(p, s, &Hum::new(ArmPose::Empty, ArmPose::Empty)); } -/// `AnimationUtils.swingWeaponDown` with the right arm as the main arm. -pub(super) fn swing_weapon_down(p: &mut Poses, swing: f32, age: f32) { +/// `AnimationUtils.swingWeaponDown`: the main arm swings down, the other +/// one hangs and bobs. +pub(super) fn swing_weapon_down(p: &mut Poses, swing: f32, age: f32, left_main: bool) { let attack2 = (swing * PI).msin(); let attack = ((1.0 - (1.0 - swing) * (1.0 - swing)) * PI).msin(); + let (main, off) = if left_main { + ("left_arm", "right_arm") + } else { + ("right_arm", "left_arm") + }; p.zrot("right_arm", 0.0); p.zrot("left_arm", 0.0); p.yrot("right_arm", PI / 20.0); p.yrot("left_arm", -PI / 20.0); - p.xrot("right_arm", -1.884_955_8 + (age * 0.09).mcos() * 0.15); - p.xrot("left_arm", -0.0 + (age * 0.19).mcos() * 0.5); - p.get("right_arm")[3] += attack2 * 2.2 - attack * 0.4; - p.get("left_arm")[3] += attack2 * 1.2 - attack * 0.4; + p.xrot(main, -1.884_955_8 + (age * 0.09).mcos() * 0.15); + p.xrot(off, -0.0 + (age * 0.19).mcos() * 0.5); + p.get(main)[3] += attack2 * 2.2 - attack * 0.4; + p.get(off)[3] += attack2 * 1.2 - attack * 0.4; bob(p, "right_arm", age, 1.0); bob(p, "left_arm", age, -1.0); } @@ -286,6 +292,8 @@ pub struct Hum { pub using_item: bool, /// The arm the current swing moves (`Some(true)` for the right one). pub swing_right_arm: Option, + /// `mainArm` is the left one (`Mob.isLeftHanded`): a mob's swing uses it. + pub left_main: bool, } impl Hum { pub fn new(right: ArmPose, left: ArmPose) -> Self { @@ -303,6 +311,7 @@ impl Hum { swim: 0.0, using_item: false, swing_right_arm: None, + left_main: false, } } } @@ -315,7 +324,7 @@ impl ArmPose { } } /// `AnimationUtils.animateCrossbowHold`. -fn crossbow_hold(p: &mut Poses, hx: f32, hy: f32, in_right: bool) { +pub(super) fn crossbow_hold(p: &mut Poses, hx: f32, hy: f32, in_right: bool) { let (hold, shoot) = if in_right { ("right_arm", "left_arm") } else { @@ -327,7 +336,7 @@ fn crossbow_hold(p: &mut Poses, hx: f32, hy: f32, in_right: bool) { p.xrot(shoot, -1.5 + hx); } /// `AnimationUtils.animateCrossbowCharge`. -fn crossbow_charge(p: &mut Poses, max: f32, ticks: f32, in_right: bool) { +pub(super) fn crossbow_charge(p: &mut Poses, max: f32, ticks: f32, in_right: bool) { let (hold, pull) = if in_right { ("right_arm", "left_arm") } else { @@ -418,13 +427,17 @@ pub(super) fn humanoid(p: &mut Poses, s: &State, h: &Hum) { pose_arm(p, h.right, true, h); } } - // setupAttackAnimation (WHACK swing with the right arm). + // setupAttackAnimation (WHACK swing with the arm of the swinging hand). let hx = p.get("head")[3]; let swing = s.swing; + let swing_left = h.swing_right_arm.map_or(h.left_main, |right| !right); if swing > 0.0 && h.weapon_swing { - swing_weapon_down(p, swing, s.age); + swing_weapon_down(p, swing, s.age, h.left_main); } else if swing > 0.0 { - let body_y = (swing.sqrt() * PI * 2.0).msin() * 0.2; + let mut body_y = (swing.sqrt() * PI * 2.0).msin() * 0.2; + if swing_left { + body_y = -body_y; + } p.yrot("body", body_y); let age_scale = if s.baby { 0.5 } else { 1.0 }; { @@ -444,7 +457,7 @@ pub(super) fn humanoid(p: &mut Poses, s: &State, h: &Hum) { let eased = 1.0 - (1.0 - swing).powi(4); let aa = (eased * PI).msin(); let bb = (swing * PI).msin() * -(hx - 0.7) * 0.75; - let r = p.get("right_arm"); + let r = p.get(if swing_left { "left_arm" } else { "right_arm" }); r[3] -= aa * 1.2 + bb; r[4] += body_y * 2.0; r[5] += (swing * PI).msin() * -0.4; @@ -652,6 +665,7 @@ pub fn setup( } else { Hum::new(main, ArmPose::Empty) }; + h.left_main = m.main_arm_left(); h.zombie = Some(m.ai.aggressive); h.holding = m.extra.main_hand.is_some(); h.crouching = m.extra.crouching; @@ -715,6 +729,7 @@ pub fn setup( h.swim = m.extra.swim.amount(s.partial); h.using_item = m.extra.using_item > 0; h.swing_right_arm = m.extra.swing_right_arm; + h.left_main = m.main_arm_left(); humanoid(p, s, &h); if m.ai.aggressive && !bow { // SkeletonModel melee pose. diff --git a/crates/horizon-client/src/mobs/illager.rs b/crates/horizon-client/src/mobs/illager.rs index a037e7c5f..9bdfec3e2 100644 --- a/crates/horizon-client/src/mobs/illager.rs +++ b/crates/horizon-client/src/mobs/illager.rs @@ -672,7 +672,12 @@ pub fn anim_pose(m: &Mob, s: &State, p: &mut Poses, pose: ArmPose) { p.xrot("right_arm", x + a * 1.2 - b * 0.4); p.xrot("left_arm", x + a * 1.2 - b * 0.4); } else { - // swingWeaponDown (right-handed). + // swingWeaponDown: the main arm swings down. + let (main, off) = if m.main_arm_left() { + ("left_arm", "right_arm") + } else { + ("right_arm", "left_arm") + }; let swing = s.swing; let a2 = (swing * PI).msin(); let a = ((1.0 - (1.0 - swing) * (1.0 - swing)) * PI).msin(); @@ -681,11 +686,11 @@ pub fn anim_pose(m: &Mob, s: &State, p: &mut Poses, pose: ArmPose) { p.yrot("right_arm", PI / 20.0); p.yrot("left_arm", -PI / 20.0); p.xrot( - "right_arm", + main, -1.884_955_8 + (s.age * 0.09).mcos() * 0.15 + (a2 * 2.2 - a * 0.4), ); p.xrot( - "left_arm", + off, -0.0 + (s.age * 0.19).mcos() * 0.5 + (a2 * 1.2 - a * 0.4), ); } diff --git a/crates/horizon-client/src/mobs/piglin.rs b/crates/horizon-client/src/mobs/piglin.rs index de9ba42dd..a057581e6 100644 --- a/crates/horizon-client/src/mobs/piglin.rs +++ b/crates/horizon-client/src/mobs/piglin.rs @@ -431,7 +431,14 @@ pub fn piglin_anim(m: &Mob, s: &State, p: &mut Poses) { } else { PiglinPose::Default }; - piglin_pose(p, s, pose, 25.0, m.extra.using_item as f32); + piglin_pose( + p, + s, + pose, + 25.0, + m.extra.using_item as f32, + m.main_arm_left(), + ); } /// `PiglinArmPose`. #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -443,11 +450,19 @@ pub enum PiglinPose { CrossbowCharge, AdmiringItem, } -/// `PiglinModel.setupAnim` for a piglin facing right-handed. -pub fn piglin_pose(p: &mut Poses, s: &State, pose: PiglinPose, max_charge: f32, ticks: f32) { - use super::anim::{ArmPose, Hum, humanoid}; +/// `PiglinModel.setupAnim`; `left` when the piglin's main arm is the left one. +pub fn piglin_pose( + p: &mut Poses, + s: &State, + pose: PiglinPose, + max_charge: f32, + ticks: f32, + left: bool, +) { + use super::anim::{ArmPose, Hum, crossbow_charge, crossbow_hold, humanoid}; let mut h = Hum::new(ArmPose::Empty, ArmPose::Empty); h.weapon_swing = pose == PiglinPose::MeleeWeapon; + h.left_main = left; h.charge = (max_charge, ticks); humanoid(p, s, &h); ears(p, s); @@ -474,27 +489,22 @@ pub fn piglin_pose(p: &mut Poses, s: &State, pose: PiglinPose, max_charge: f32, p.get("left_arm")[1] += (dance * 40.0).msin() * 0.5 + 0.5; p.get("body")[1] += (dance * 40.0).msin() * 0.35; } - PiglinPose::MeleeWeapon if s.swing == 0.0 => p.xrot("right_arm", -1.8), - PiglinPose::CrossbowHold => { - p.yrot("right_arm", -0.3 + hy); - p.yrot("left_arm", 0.6 + hy); - p.xrot("right_arm", -PI / 2.0 + hx + 0.1); - p.xrot("left_arm", -1.5 + hx); - } - PiglinPose::CrossbowCharge => { - p.yrot("right_arm", -0.8); - p.xrot("right_arm", -0.970_796_35); - p.xrot("left_arm", -0.970_796_35); - let alpha = ticks.clamp(0.0, max_charge) / max_charge; - p.yrot("left_arm", 0.4 + alpha * (0.85 - 0.4)); - let x = -0.970_796_35 + alpha * (-PI / 2.0 - -0.970_796_35); - p.xrot("left_arm", x); + // holdWeaponHigh + PiglinPose::MeleeWeapon if s.swing == 0.0 => { + p.xrot(if left { "left_arm" } else { "right_arm" }, -1.8) } + PiglinPose::CrossbowHold => crossbow_hold(p, hx, hy, !left), + PiglinPose::CrossbowCharge => crossbow_charge(p, max_charge, ticks, !left), PiglinPose::AdmiringItem => { p.xrot("head", 0.5); p.yrot("head", 0.0); - p.yrot("left_arm", 0.5); - p.xrot("left_arm", -0.9); + if left { + p.yrot("right_arm", -0.5); + p.xrot("right_arm", -0.9); + } else { + p.yrot("left_arm", 0.5); + p.xrot("left_arm", -0.9); + } } _ => {} } From 46b71954e162c8b355e26d8afb132d2060bf5fcf Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 20:38:38 +0100 Subject: [PATCH 02/15] Make the High Contrast option turn its resource pack on and off --- crates/horizon-client/src/options_ui.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/horizon-client/src/options_ui.rs b/crates/horizon-client/src/options_ui.rs index 61fda9878..b6a3a0f3e 100644 --- a/crates/horizon-client/src/options_ui.rs +++ b/crates/horizon-client/src/options_ui.rs @@ -2533,6 +2533,17 @@ impl OptionsUi { if opt == Opt::Preset { apply_preset(s); } + if opt == Opt::HighContrast { + // Options.highContrast: the built-in pack follows the option. + let on = s.resource_packs.iter().any(|id| id == "high_contrast"); + if on != s.high_contrast { + s.resource_packs.retain(|id| id != "high_contrast"); + if s.high_contrast { + s.resource_packs.push("high_contrast".into()); + } + events.push(Event::Packs(s.resource_packs.clone())); + } + } events.push(Event::Changed); } Act::Extra(item) => { From 4201fd23c0dda6ab5ff3624cc79e4c322800980c Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 20:39:05 +0100 Subject: [PATCH 03/15] Use real eye heights in /execute and keep the anchor on positioned as --- .../src/game/commands/execute.rs | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/game/commands/execute.rs b/crates/horizon-client/src/game/commands/execute.rs index 3f7e4c2a0..c48cd8adf 100644 --- a/crates/horizon-client/src/game/commands/execute.rs +++ b/crates/horizon-client/src/game/commands/execute.rs @@ -145,9 +145,44 @@ impl Game<'_> { .iter() .find(|m| m.id == id) .map_or(0.0, |m| m.eye_y() - m.position.y), - _ => 0.0, + // An armor stand's dimensions are halved when small and empty + // when a marker (ArmorStand.getDefaultDimensions). + Target::Stand(id) => { + let stand = self.armor_stands.iter().find(|a| a.id == id); + let scale = match stand { + Some(a) if a.marker => 0.0, + Some(a) if a.small => 0.5, + _ => 1.0, + }; + scale * self.type_eye_height(&self.target_type(t)) + } + // Entity.getEyeHeight: the type's dimensions. + _ => self.type_eye_height(&self.target_type(t)), } } + /// `EntityType.getDimensions().eyeHeight()` from `entity-types.json`, + /// read once. + fn type_eye_height(&self, ty: &str) -> f64 { + static EYE_HEIGHTS: std::sync::OnceLock> = + std::sync::OnceLock::new(); + EYE_HEIGHTS + .get_or_init(|| { + std::fs::read(self.options.resources.join("entity-types.json")) + .ok() + .and_then(|b| serde_json::from_slice::(&b).ok()) + .and_then(|v| { + v.as_object().map(|o| { + o.iter() + .filter_map(|(k, t)| Some((k.clone(), t["eye_height"].as_f64()?))) + .collect() + }) + }) + .unwrap_or_default() + }) + .get(ty) + .copied() + .unwrap_or(0.0) + } /// EntityAnchorArgument.Anchor.apply. pub(super) fn anchor_position(&self, s: &Source) -> [f64; 3] { match s.entity { @@ -467,9 +502,10 @@ impl Game<'_> { "positioned" if c.has("as") => targets(self)? .into_iter() .filter_map(|t| { + // withPosition keeps the anchor (only `positioned ` + // resets it to the feet). Some(Source { pos: self.target_position(t)?, - eyes: false, ..s }) }) From ad6f2320b0a6bbfaa016f9b1f978d8348989015a Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 20:40:06 +0100 Subject: [PATCH 04/15] Wire the Music Frequency option to the music manager --- crates/horizon-client/src/game.rs | 9 ++++++++- crates/horizon-client/src/game/music.rs | 7 ++++++- crates/horizon-client/src/options_ui.rs | 15 ++++++++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 20f6e01bc..0e4756abf 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -12645,7 +12645,14 @@ impl<'a> Game<'a> { level, session_lock: None, audio, - music: Default::default(), + music: { + // The manager starts with the saved option (MusicManager's constructor). + let mut music = horizon_client::music::MusicManager::default(); + music.frequency = horizon_client::music::MusicFrequency::parse( + &settings.file.name("musicFrequency"), + ); + music + }, ambience: Default::default(), sound_paused: false, cart_sounds: HashSet::new(), diff --git a/crates/horizon-client/src/game/music.rs b/crates/horizon-client/src/game/music.rs index fa5e71f7b..97ca3763e 100644 --- a/crates/horizon-client/src/game/music.rs +++ b/crates/horizon-client/src/game/music.rs @@ -3,7 +3,7 @@ use super::Game; use horizon_client::{ blocks::Fluid, - music::{BackgroundMusic, Music, Situation}, + music::{BackgroundMusic, Music, MusicFrequency, Situation}, sound_engine::TickContext, }; @@ -11,6 +11,11 @@ impl Game<'_> { /// `Minecraft.tick` -> `MusicManager.tick`, once per client tick. pub(super) fn tick_music(&mut self) { let (music, volume) = self.situational_music(); + // Options.musicFrequency's listener: MusicManager.setMinutesBetweenSongs. + let frequency = MusicFrequency::parse(&self.settings.file.name("musicFrequency")); + if frequency != self.music.frequency { + self.music.set_frequency(frequency, music.as_ref()); + } // LevelLoadingScreen: no new track before the player is in the world. let loading = self.title.is_none() && self.player.is_none() && self.win.is_none(); self.music diff --git a/crates/horizon-client/src/options_ui.rs b/crates/horizon-client/src/options_ui.rs index 61fda9878..50eb50f6f 100644 --- a/crates/horizon-client/src/options_ui.rs +++ b/crates/horizon-client/src/options_ui.rs @@ -67,6 +67,7 @@ pub enum Opt { ReducedDebugInfo, HighContrast, ShowSubtitles, + MusicFrequency, NotificationDisplayTime, Narrator, TextBackground, @@ -192,6 +193,7 @@ impl Opt { Opt::NarratorHotkey => "narratorHotkey", Opt::RotateWithMinecarts => "rotateWithMinecart", Opt::HighContrastBlockOutlines => "highContrastBlockOutline", + Opt::MusicFrequency => "musicFrequency", _ => return None, }) } @@ -248,6 +250,7 @@ impl Opt { Opt::ReducedDebugInfo => "options.reducedDebugInfo", Opt::HighContrast => "options.accessibility.high_contrast", Opt::ShowSubtitles => "options.showSubtitles", + Opt::MusicFrequency => "options.music_frequency", Opt::NotificationDisplayTime => "options.notifications.display_time", Opt::Narrator => "options.narrator", Opt::TextBackground => "options.accessibility.text_background", @@ -578,6 +581,11 @@ impl Opt { Opt::ReducedDebugInfo => on_off(s.reduced_debug_info), Opt::HighContrast => on_off(s.high_contrast), Opt::ShowSubtitles => on_off(s.show_subtitles), + Opt::MusicFrequency => tr([ + "options.music_frequency.default", + "options.music_frequency.frequent", + "options.music_frequency.constant", + ][s.file.int("musicFrequency").clamp(0, 2) as usize]), Opt::ForceUnicode => on_off(s.force_unicode), Opt::JapaneseGlyphs => on_off(s.japanese_glyphs), Opt::PadEnabled => on_off(s.controller.enabled), @@ -747,6 +755,11 @@ impl Opt { Opt::ReducedDebugInfo => s.reduced_debug_info = !s.reduced_debug_info, Opt::HighContrast => s.high_contrast = !s.high_contrast, Opt::ShowSubtitles => s.show_subtitles = !s.show_subtitles, + Opt::MusicFrequency => { + let n = next(s.file.int("musicFrequency").clamp(0, 2) as u8, 3); + s.file + .set("musicFrequency", crate::options_file::V::Int(i32::from(n))); + } Opt::ForceUnicode => s.force_unicode = !s.force_unicode, Opt::JapaneseGlyphs => s.japanese_glyphs = !s.japanese_glyphs, Opt::PadEnabled => s.controller.enabled = !s.controller.enabled, @@ -1411,7 +1424,7 @@ impl OptionsUi { let mut rows = vec![Row::Big(Opt::Volume(0))]; let others: Vec = (1..SOUND_SOURCES.len()).map(Opt::Volume).collect(); rows.extend(pairs(&others)); - rows.extend(pairs(&[Opt::ShowSubtitles])); + rows.extend(pairs(&[Opt::ShowSubtitles, Opt::MusicFrequency])); rows } Page::Controls => { From 34dabe4afdfafd89c5bb1240843d4253d4f74fa2 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 20:41:49 +0100 Subject: [PATCH 05/15] Grey out Chunk Fade-in, Improved Transparency and Chunk Builder --- crates/horizon-client/src/options_ui.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/horizon-client/src/options_ui.rs b/crates/horizon-client/src/options_ui.rs index 61fda9878..d441819d8 100644 --- a/crates/horizon-client/src/options_ui.rs +++ b/crates/horizon-client/src/options_ui.rs @@ -172,6 +172,10 @@ impl Opt { | Opt::MonochromeLogo | Opt::RotateWithMinecarts | Opt::HighContrastBlockOutlines + // Saved, but nothing in rendering reads them yet. + | Opt::ChunkFade + | Opt::ImprovedTransparency + | Opt::ChunkBuilder ) } fn file_key(self) -> Option<&'static str> { From 0e96fb6d2a87ba22b6a640ac27d6a075b8626214 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 21:21:06 +0100 Subject: [PATCH 06/15] Disable unavailable options in the Graphics Advanced screen --- crates/horizon-client/src/graphics_style.rs | 3 +- crates/horizon-client/src/graphics_ui.rs | 33 ++++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/graphics_style.rs b/crates/horizon-client/src/graphics_style.rs index e02a0e1d9..62979903b 100644 --- a/crates/horizon-client/src/graphics_style.rs +++ b/crates/horizon-client/src/graphics_style.rs @@ -118,8 +118,9 @@ impl Style { (x, y, w): (f32, f32, f32), label: &Text, hover: bool, + active: bool, ) { - ui::button(batch, atlas, x, y, w, 20.0, label, true, hover); + ui::button(batch, atlas, x, y, w, 20.0, label, active, hover); } pub fn slider( &self, diff --git a/crates/horizon-client/src/graphics_ui.rs b/crates/horizon-client/src/graphics_ui.rs index 3c7a40e02..d55e44d99 100644 --- a/crates/horizon-client/src/graphics_ui.rs +++ b/crates/horizon-client/src/graphics_ui.rs @@ -468,6 +468,10 @@ fn max_workers() -> u32 { } impl Item { + /// False for a setting whose system is not in Horizon yet (`Opt::available`). + fn available(self) -> bool { + !matches!(self, Item::Vanilla(o) if !o.available()) + } /// On/off settings and their value. pub fn switch(self, s: &Settings) -> Option { let g = &s.horizon; @@ -510,6 +514,9 @@ impl Item { } } pub fn set_slider(self, s: &mut Settings, v: f32) { + if !self.available() { + return; + } match self { Item::Vanilla(o) => o.set_slider(s, v), Item::Horizon(h) => h.set_slider(s, v), @@ -517,6 +524,9 @@ impl Item { self.touched(s); } pub fn cycle(self, s: &mut Settings, back: bool, framebuffer: [i32; 2]) { + if !self.available() { + return; + } match self { Item::Vanilla(o) => o.cycle(s, back, framebuffer), Item::Horizon(h) => h.cycle(s, back), @@ -689,6 +699,7 @@ impl GraphicsUi { }) .collect(); let mut index = 0; + let mut tooltip = None; for wd in &widgets { let hover = ui::hovered(cursor, wd.x, wd.y, wd.w, 20.0) && (!wd.list || (cursor.1 >= top && cursor.1 < bottom)); @@ -700,6 +711,13 @@ impl GraphicsUi { continue; } let label = item.label(s); + let live = item.available(); + if hover && !live { + tooltip = Some(atlas.font.split( + &Text::literal("This feature is not yet available in Horizon."), + 170.0, + )); + } match item.slider(s) { Some(value) => STYLE.slider( batch, @@ -709,7 +727,14 @@ impl GraphicsUi { value, hover || self.dragging == Some(item), ), - None => STYLE.button(batch, atlas, (wd.x, wd.y, wd.w), &label, hover), + None => STYLE.button( + batch, + atlas, + (wd.x, wd.y, wd.w), + &label, + hover && live, + live, + ), } STYLE.description( batch, @@ -732,6 +757,7 @@ impl GraphicsUi { (wd.x, wd.y, wd.w), &Text::literal(label), hover, + true, ); } } @@ -751,6 +777,9 @@ impl GraphicsUi { Level::Advanced => "Graphics: Advanced", }; STYLE.title(batch, atlas, &Text::literal(title)); + if let Some(lines) = tooltip { + ui::tooltip(batch, atlas, &lines, cursor); + } } /// A press (or a drag with `drag`) at `(x, y)`. pub fn click( @@ -788,6 +817,8 @@ impl GraphicsUi { } return match wd.target { Target::Button(action) => vec![Action::ButtonClick, action], + // A disabled control does nothing: no sound, no preset change. + Target::Item(item) if !item.available() => Vec::new(), Target::Item(item) => { if item.slider(s).is_some() { self.dragging = Some(item); From 56bf45cee512556c8c0a01eea04371876a117606 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 21:23:03 +0100 Subject: [PATCH 07/15] Keep the pack screen selection in step with High Contrast --- crates/horizon-client/src/options_ui.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/horizon-client/src/options_ui.rs b/crates/horizon-client/src/options_ui.rs index b6a3a0f3e..9170fd66e 100644 --- a/crates/horizon-client/src/options_ui.rs +++ b/crates/horizon-client/src/options_ui.rs @@ -2541,6 +2541,10 @@ impl OptionsUi { if s.high_contrast { s.resource_packs.push("high_contrast".into()); } + // PackSelectionScreen reads the repository each time it + // opens: the next one starts from this selection. + self.pack_selection = s.resource_packs.clone(); + self.pack_screen = None; events.push(Event::Packs(s.resource_packs.clone())); } } @@ -2712,6 +2716,7 @@ impl OptionsUi { { let ids = p.commit(); s.resource_packs = ids.clone(); + self.pack_selection = ids.clone(); events.push(Event::Packs(ids)); } } From c4d0cb1ec0c686b4efba990964055795af0f2576 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Mon, 26 Oct 2026 21:55:51 +0100 Subject: [PATCH 08/15] A small armor stand's eyes are at 0.9875, and eye heights are floats ArmorStand.BABY_DIMENSIONS keeps its own eye height rather than half the type's, and EntityDimensions.eyeHeight is a float widened by getEyeY. Co-Authored-By: Claude Opus 5.5 --- .../src/game/commands/execute.rs | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/crates/horizon-client/src/game/commands/execute.rs b/crates/horizon-client/src/game/commands/execute.rs index c48cd8adf..d715ce0ab 100644 --- a/crates/horizon-client/src/game/commands/execute.rs +++ b/crates/horizon-client/src/game/commands/execute.rs @@ -145,23 +145,19 @@ impl Game<'_> { .iter() .find(|m| m.id == id) .map_or(0.0, |m| m.eye_y() - m.position.y), - // An armor stand's dimensions are halved when small and empty - // when a marker (ArmorStand.getDefaultDimensions). - Target::Stand(id) => { - let stand = self.armor_stands.iter().find(|a| a.id == id); - let scale = match stand { - Some(a) if a.marker => 0.0, - Some(a) if a.small => 0.5, - _ => 1.0, - }; - scale * self.type_eye_height(&self.target_type(t)) - } + // ArmorStand.getDefaultDimensions: a marker's are empty, a small + // stand's are BABY_DIMENSIONS, whose eye height is 0.9875F. + Target::Stand(id) => match self.armor_stands.iter().find(|a| a.id == id) { + Some(a) if a.marker => 0.0, + Some(a) if a.small => f64::from(0.9875f32), + _ => self.type_eye_height(&self.target_type(t)), + }, // Entity.getEyeHeight: the type's dimensions. _ => self.type_eye_height(&self.target_type(t)), } } /// `EntityType.getDimensions().eyeHeight()` from `entity-types.json`, - /// read once. + /// read once: a float, widened as `Entity.getEyeY` does. fn type_eye_height(&self, ty: &str) -> f64 { static EYE_HEIGHTS: std::sync::OnceLock> = std::sync::OnceLock::new(); @@ -173,7 +169,9 @@ impl Game<'_> { .and_then(|v| { v.as_object().map(|o| { o.iter() - .filter_map(|(k, t)| Some((k.clone(), t["eye_height"].as_f64()?))) + .filter_map(|(k, t)| { + Some((k.clone(), f64::from(t["eye_height"].as_f64()? as f32))) + }) .collect() }) }) From 1fe0f5fcb9690f3dd3886153960ada3a63c6635e Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Mon, 26 Oct 2026 21:59:39 +0100 Subject: [PATCH 09/15] Sound options: Music Frequency starts its own row, as in SoundOptionsScreen Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/options_ui.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/horizon-client/src/options_ui.rs b/crates/horizon-client/src/options_ui.rs index 50eb50f6f..f599176db 100644 --- a/crates/horizon-client/src/options_ui.rs +++ b/crates/horizon-client/src/options_ui.rs @@ -1424,7 +1424,10 @@ impl OptionsUi { let mut rows = vec![Row::Big(Opt::Volume(0))]; let others: Vec = (1..SOUND_SOURCES.len()).map(Opt::Volume).collect(); rows.extend(pairs(&others)); - rows.extend(pairs(&[Opt::ShowSubtitles, Opt::MusicFrequency])); + rows.extend(pairs(&[Opt::ShowSubtitles])); + // SoundOptionsScreen: Music Frequency starts the next row (with + // Music Toast, not in Horizon yet). + rows.extend(pairs(&[Opt::MusicFrequency])); rows } Page::Controls => { From bedba4a3d9a4bf2d3fe5e873ca49f8b6a1009c2c Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 27 Oct 2026 01:08:50 +0100 Subject: [PATCH 10/15] lan_e2e fireworks: count newly red pixels, take the later shots 4 ticks after the burst On playhorizon (frames drawn on the CPU) a screenshot takes ~0.6 s: with a 16-tick wait the later shots came after the sparks' lifetime, and the setup's own red chat lines, gone by then, made the host's count negative. Co-Authored-By: Claude Opus 5.5 --- tools/lan_e2e.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tools/lan_e2e.py b/tools/lan_e2e.py index 03e0e888f..fe76b288b 100755 --- a/tools/lan_e2e.py +++ b/tools/lan_e2e.py @@ -2971,13 +2971,15 @@ def check_fireworks(host, guest, out): game('command', command=f'tp @s {x + dx + 0.5} {y} {z + 0.5}') game.raw('look-at', x + 0.5, y + 1.5, z + 3.5) - def red(path): + def reds(path): + """The red pixels' positions, above the hotbar.""" rows, bpp = png_rows(path) - # Exclude the hotbar and chat at the bottom of the view. - return sum(row[i] > 80 and row[i] > 2 * row[i + 1] and row[i] > 2 * row[i + 2] - for row in rows[:len(rows) * 3 // 4] for i in range(0, len(row), bpp)) + return {(y, i) for y, row in enumerate(rows[:len(rows) * 3 // 4]) for i in range(0, len(row), bpp) + if row[i] > 80 and row[i] > 2 * row[i + 1] and row[i] > 2 * row[i + 2]} - baseline = {g.name: red(g.shot(out, 'fireworks-before')) for g in (host, guest)} + # Red where the view had none: the setup's own red chat lines (a fill that changed nothing) are in the + # baseline, and fade out before the later shots, which a plain count difference would take as missing sparks. + baseline = {g.name: reds(g.shot(out, 'fireworks-before')) for g in (host, guest)} before = {g.name: made(g, 'flash') for g in (host, guest)} host('command', command='item replace entity @s weapon.mainhand with minecraft:firework_rocket' '[fireworks={flight_duration:0,explosions:[{shape:"large_ball",colors:[I;16711680],has_trail:true}]}]') @@ -2990,12 +2992,14 @@ def check_fireworks(host, guest, out): break flashes = {g.name: made(g, 'flash') - before[g.name] for g in (host, guest)} assert all(n == 1 for n in flashes.values()), f'configured burst missing or duplicated: {flashes}' - # Capture both views before decoding PNGs: decoding must not consume the sparks' lifetime. + # Capture both views before decoding PNGs: decoding must not consume the sparks' lifetime (48-59 ticks). A + # screenshot takes ~0.6 s where the frame is drawn on the CPU (lavapipe), so the later shots come 4 ticks after + # the burst's, not more: by then the tracked rocket is gone. burst_shots = {g.name: g.shot(out, 'fireworks-burst') for g in (host, guest)} - host.wait(16) + host.wait(4) trail_shots = {g.name: g.shot(out, 'fireworks-trail-fade') for g in (host, guest)} - burst = {name: red(path) - baseline[name] for name, path in burst_shots.items()} - trails = {name: red(path) - baseline[name] for name, path in trail_shots.items()} + burst = {name: len(reds(path) - baseline[name]) for name, path in burst_shots.items()} + trails = {name: len(reds(path) - baseline[name]) for name, path in trail_shots.items()} rockets = {g.name: g('status')['rockets'] for g in (host, guest)} assert not any(rockets.values()), f'exploded rocket remains: {rockets}' assert all(n > 20 for n in burst.values()), f'no red burst: {burst}' From 90f27552459e7868afad4a8527149eb790db6c0c Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 27 Oct 2026 01:25:31 +0100 Subject: [PATCH 11/15] Launcher: a Horizon version per instance An instance plays the launcher's version, which follows updates, unless it is kept on another installed one: the Play page's picker pins the selected instance (picking the version marked "follows updates" unpins it), and `instance version ` does it from the CLI. play, `play --instance` and MCP play use the pin; a pack's Play uses its instance's. The sidebar shows a pinned instance's version, or that it is not installed. Co-Authored-By: Claude Opus 5.5 --- docs/launcher-commands.md | 10 +++++++++ launcher/README.md | 5 ++++- launcher/src/cli.rs | 19 +++++++++++++++-- launcher/src/instances.rs | 24 +++++++++++++++++++++ launcher/src/instances/tests.rs | 23 ++++++++++++++++++++ launcher/src/instances_page.rs | 38 ++++++++++++++++++++++++--------- launcher/src/main.rs | 32 +++++++++++++++++++++------ launcher/src/mcp.rs | 6 +++--- launcher/src/modpacks_page.rs | 8 ++++++- 9 files changed, 142 insertions(+), 23 deletions(-) diff --git a/docs/launcher-commands.md b/docs/launcher-commands.md index e233cc9a9..6faaeed74 100644 --- a/docs/launcher-commands.md +++ b/docs/launcher-commands.md @@ -320,6 +320,16 @@ Make Play start this instance. MCP: `instance_select`. +## `horizon-launcher instance version` + +Keep an instance on one installed Horizon version, or "latest" to follow updates again. + + horizon-launcher instance version + +- `INSTANCE` + +MCP: `instance_version`. + ## `horizon-launcher modpack list` The imported packs and their coverage (the default). diff --git a/launcher/README.md b/launcher/README.md index 50ca6829c..ea4ebc39c 100644 --- a/launcher/README.md +++ b/launcher/README.md @@ -78,7 +78,9 @@ The opening, then Play ([clip](docs/opening.webm)): data folder, so renaming moves nothing. Every instance follows the launcher's data collection answer and No AI. In the window, **+** beside Instances makes one, the sidebar lists them by group (click one to play it), and Home's Instance row has Edit (name, group, icon), Copy and - Open folder. + Open folder. Each instance plays the launcher's version, which follows updates, unless the Play + page's version picker keeps it on another installed one (to keep an old world on the version + it was made with); picking the version marked "follows updates" lets it follow again. - **Patch notes**: each release's notes, newest first, with a link to GitHub Sponsors. Quiet "Discord" and "Website" links sit in the footer. Data lives in the platform's data directory (`~/.local/share/horizon-launcher` on Linux, @@ -178,6 +180,7 @@ and don't set `%ERRORLEVEL%` / `$LASTEXITCODE`. Scripts that need the exit code horizon-launcher instance create [--copy ] empty, or a copy of one's worlds, options and packs horizon-launcher instance rename|icon|group icon: a block or item name, #rrggbb or none horizon-launcher instance select make Play start it + horizon-launcher instance version keep it on one installed version, or follow updates horizon-launcher modpack [list] the imported packs and their coverage horizon-launcher modpack import a .mrpack, CurseForge zip or instance folder horizon-launcher modpack port [--from ] [--version ] get the jars and carry them over diff --git a/launcher/src/cli.rs b/launcher/src/cli.rs index 22a850c02..8addbd191 100644 --- a/launcher/src/cli.rs +++ b/launcher/src/cli.rs @@ -180,6 +180,8 @@ enum InstanceCmd { }, /// Make Play start this instance Select { instance: String }, + /// Keep an instance on one installed Horizon version, or "latest" to follow updates again + Version { instance: String, version: String }, } #[derive(Subcommand)] @@ -647,11 +649,11 @@ fn execute(command: Cmd, as_json: bool) -> Result<(), String> { join, arg, } => { - let mut cmd = backend::client(&backend::resolve_version(version.as_deref())?)?; let instance = match instance { Some(name) => instances::find(&name)?, None => instances::selected(), }; + let mut cmd = backend::client(&instance.resolve_version(version.as_deref())?)?; instances::apply(&mut cmd, &instance)?; if let Some(code) = join { backend::join_friend(&mut cmd, &code)?; @@ -1385,6 +1387,7 @@ fn instance(action: InstanceCmd, as_json: bool) -> Result<(), String> { serde_json::json!({ "id": i.id, "name": i.name, "kind": format!("{:?}", i.kind).to_lowercase(), "home": i.home, "icon": i.icon, "group": i.group, "selected": selected, + "version": i.version, }) }; let line = |i: &instances::Instance, selected: bool| { @@ -1394,8 +1397,13 @@ fn instance(action: InstanceCmd, as_json: bool) -> Result<(), String> { .as_ref() .map(|g| format!(" [{g}]")) .unwrap_or_default(); + let pinned = i + .version + .as_ref() + .map(|v| format!(" {v}")) + .unwrap_or_default(); println!( - "{mark} {} ({}){group}\n {}", + "{mark} {} ({}){pinned}{group}\n {}", i.name, i.id, i.home.display() @@ -1430,6 +1438,13 @@ fn instance(action: InstanceCmd, as_json: bool) -> Result<(), String> { changed(instances::edit(&instance, |m| m.group = group)?) } InstanceCmd::Select { instance } => changed(instances::select(&instance)?), + InstanceCmd::Version { instance, version } => { + let pin = match version.as_str() { + "latest" => None, + tag => Some(backend::resolve_version(Some(tag))?), + }; + changed(instances::edit(&instance, |m| m.version = pin)?) + } } Ok(()) } diff --git a/launcher/src/instances.rs b/launcher/src/instances.rs index d2e74dde1..4945ba813 100644 --- a/launcher/src/instances.rs +++ b/launcher/src/instances.rs @@ -86,6 +86,10 @@ pub struct Meta { pub icon: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub group: Option, + /// The Horizon version this instance plays, kept when newer ones are installed. None: the + /// launcher's own version, which follows updates. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub version: Option, } /// `instances.json`: each instance's choices, by id. @@ -121,6 +125,25 @@ pub struct Instance { pub home: PathBuf, pub icon: Option, pub group: Option, + /// Its pinned Horizon version, if any (`Meta::version`). + pub version: Option, +} + +impl Instance { + /// The installed version this instance plays: its pinned one, else `requested` (the + /// command line's `--version`) or the launcher's (`backend::resolve_version`). + pub fn resolve_version(&self, requested: Option<&str>) -> Result { + match (requested, &self.version) { + (None, Some(pinned)) => backend::resolve_version(Some(pinned)).map_err(|_| { + format!( + "{} plays {pinned}, which is not installed: install it, or horizon-launcher \ + instance version \"{}\" latest", + self.name, self.name + ) + }), + _ => backend::resolve_version(requested), + } + } } /// The instances, by the default game home and the launcher's data folder: Horizon first, then @@ -172,6 +195,7 @@ fn list_in(game_home: &Path, data: &Path) -> Vec { name: meta.name.unwrap_or(name), icon: meta.icon, group: meta.group, + version: meta.version, id, kind, work, diff --git a/launcher/src/instances/tests.rs b/launcher/src/instances/tests.rs index 586b620b3..f1c94f5b8 100644 --- a/launcher/src/instances/tests.rs +++ b/launcher/src/instances/tests.rs @@ -201,3 +201,26 @@ fn icons_are_a_texture_name_or_a_colour() { assert_eq!(Icon::Texture("stone".into()).texture(&root), None); fs::remove_dir_all(&root).unwrap(); } + +#[test] +fn an_instance_keeps_its_own_version_until_it_follows_updates_again() { + let root = scratch("version"); + let (home, data) = (root.join("horizon"), root.join("launcher")); + player_home(&home); + create_in(&home, &data, "Old world", None).unwrap(); + let pinned = edit_in(&home, &data, "Old world", |m| { + m.version = Some("v0.1.0".into()) + }) + .unwrap(); + assert_eq!(pinned.version.as_deref(), Some("v0.1.0")); + // Renaming keeps it; the other instances follow the launcher's version. + let renamed = edit_in(&home, &data, "old-world", |m| m.name = Some("Older".into())).unwrap(); + assert_eq!(renamed.version.as_deref(), Some("v0.1.0")); + assert!(list_in(&home, &data) + .iter() + .filter(|i| i.id != "old-world") + .all(|i| i.version.is_none())); + let follows = edit_in(&home, &data, "Older", |m| m.version = None).unwrap(); + assert_eq!(follows.version, None); + fs::remove_dir_all(&root).unwrap(); +} diff --git a/launcher/src/instances_page.rs b/launcher/src/instances_page.rs index ce6c1d42e..a414ca227 100644 --- a/launcher/src/instances_page.rs +++ b/launcher/src/instances_page.rs @@ -77,6 +77,25 @@ impl Launcher { list.iter().find(|i| i.id == id).or(list.first()) } + /// The installed version `instance` plays: its own, else the launcher's. + pub(super) fn version_of(&self, instance: &Instance) -> Option<&String> { + match &instance.version { + Some(own) => self.installed.iter().find(|t| *t == own), + None => self.launcher_version(), + } + } + + /// Keeps the selected instance on `tag`, or lets it follow the launcher's version. + pub(super) fn pin_version(&mut self, tag: Option) { + let Some(id) = self.selected_instance().map(|i| i.id.clone()) else { + return; + }; + match instances::edit(&id, |m| m.version = tag) { + Ok(_) => self.reload_instances(), + Err(e) => self.client_error = Some(e), + } + } + fn select_instance(&mut self, instance: &Instance) { self.settings.instance = (instance.kind != InstanceKind::Default).then(|| instance.id.clone()); @@ -154,15 +173,6 @@ impl Launcher { cx: &mut Context, ) -> Vec { let t = self.theme; - let tag = self.selected().cloned(); - let prepared = tag.as_deref().is_some_and(backend::is_prepared); - let status = if tag.is_none() { - "No version installed" - } else if prepared { - "Ready" - } else { - "Needs preparing" - }; let selected = self.selected_instance().map(|i| i.id.clone()); let on_packs = self.page == Page::Mods && self.mods.on_modpacks(); let mut out = Vec::new(); @@ -174,10 +184,18 @@ impl Launcher { out.push(heading(g.to_uppercase()).into_any_element()); } } + let tag = self.version_of(&i).cloned(); + let prepared = tag.as_deref().is_some_and(backend::is_prepared); let (open, sub) = match i.kind { InstanceKind::Default | InstanceKind::Own => ( self.page == Page::Play && selected.as_ref() == Some(&i.id), - status.to_string(), + match (&tag, &i.version) { + (None, Some(own)) => format!("{own} is not installed"), + (None, None) => "No version installed".into(), + (Some(_), _) if !prepared => "Needs preparing".into(), + (Some(tag), Some(_)) => format!("Ready · {tag}"), + (Some(_), None) => "Ready".into(), + }, ), InstanceKind::Port => { let slug = &i.id["port:".len()..]; diff --git a/launcher/src/main.rs b/launcher/src/main.rs index b9f556d69..de87ceecc 100644 --- a/launcher/src/main.rs +++ b/launcher/src/main.rs @@ -764,7 +764,15 @@ impl Launcher { switched } + /// The version Play starts: the selected instance's own, else the launcher's. fn selected(&self) -> Option<&String> { + self.selected_instance() + .and_then(|i| self.version_of(i)) + .or_else(|| self.launcher_version()) + } + + /// The launcher's version: what instances without one of their own play. + fn launcher_version(&self) -> Option<&String> { self.settings .selected .as_ref() @@ -1850,16 +1858,20 @@ impl Launcher { .absolute() .top(px(66.)) .right_0() - .w(px(240.)) + .w(px(300.)) .p(px(6.)) .border_2() .border_color(t.outline) .bg(t.surface) .flex() .flex_col(); + // Picking a version keeps the selected instance on it; the launcher's own version + // (newest unless chosen otherwise on Versions) follows updates. + let follows = self.launcher_version().cloned(); for tag in &self.installed { let selected = self.selected() == Some(tag); let tag = tag.clone(); + let latest = follows.as_ref() == Some(&tag); menu = menu.child( div() .id(SharedString::from(format!("pick-{tag}"))) @@ -1875,12 +1887,20 @@ impl Launcher { .cursor_pointer() .hover(move |s| s.bg(t.plate_soft)) .child(tag.clone()) - .when(selected, |d| { - d.child(div().size(px(6.)).rounded_full().bg(t.accent)) - }) + .child( + div() + .flex() + .items_center() + .gap(px(8.)) + .when(latest, |d| { + d.child(caps("follows updates").text_color(t.muted)) + }) + .when(selected, |d| { + d.child(div().size(px(6.)).rounded_full().bg(t.accent)) + }), + ) .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { - this.settings.selected = Some(tag.clone()); - this.settings.save(); + this.pin_version((!latest).then(|| tag.clone())); this.picker_open = false; cx.notify(); })), diff --git a/launcher/src/mcp.rs b/launcher/src/mcp.rs index cb4636429..d03f3d567 100644 --- a/launcher/src/mcp.rs +++ b/launcher/src/mcp.rs @@ -25,7 +25,7 @@ struct Session { /// The tools the session runs itself, under their CLI names: they keep a process (the game, a /// server) or a sign-in going between calls. Every other CLI command is generated (cli_tools.rs). fn session_tools() -> Value { - let version = json!({ "type": "string", "description": "An installed version tag such as v2026.10.13. Default: the selected version." }); + let version = json!({ "type": "string", "description": "An installed version tag such as v2026.10.13. Default: the selected version (play: the instance's own first)." }); let none = json!({ "type": "object", "properties": {} }); json!([ { "name": "play", "description": "Start the Horizon client (a game window on the player's screen) under agent control: the game_* tools then play it. Returns once it has started; game_wait_ready waits for the world. CLI: horizon-launcher play", @@ -68,12 +68,12 @@ impl Session { if self.client.as_ref().is_some_and(|c| c.finished().is_none()) { return Err("The client is already running.".into()); } - let tag = backend::resolve_version(arg_str(args, "version"))?; - let mut cmd = backend::client(&tag)?; let instance = match arg_str(args, "instance") { Some(name) => instances::find(name)?, None => instances::selected(), }; + let tag = instance.resolve_version(arg_str(args, "version"))?; + let mut cmd = backend::client(&tag)?; instances::apply(&mut cmd, &instance)?; cmd.args(game_tools::control_args()); if let Some(world) = arg_str(args, "world") { diff --git a/launcher/src/modpacks_page.rs b/launcher/src/modpacks_page.rs index 2f10b2773..7f1b95ad9 100644 --- a/launcher/src/modpacks_page.rs +++ b/launcher/src/modpacks_page.rs @@ -116,7 +116,13 @@ impl Launcher { } fn play_pack(&mut self, work: PathBuf) { - let Some(tag) = self.selected().cloned() else { + // The pack's instance plays its own version, if it has one. + let pack = self.instances.list.iter().find(|i| i.work == work); + let Some(tag) = pack + .and_then(|i| self.version_of(i)) + .or_else(|| self.launcher_version()) + .cloned() + else { return; }; if self.client.is_some() || self.starting_client.is_some() { From c70e2fae7411ab094c5f5a37d186dab9ee7c1b9e Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 27 Oct 2026 01:37:31 +0100 Subject: [PATCH 12/15] Launcher: worlds of an instance, with backup, copy and delete Home lists the selected instance's worlds from their level.dat (name, mode, version, last played) with their size and picture. Back up zips one into backups/ as vanilla's Make Backup does; Copy makes " (1)" with that name in its level.dat; Delete moves it to the system's trash after a confirmation (the file manager call on macOS, no Finder permission); Open folder. `horizon-launcher worlds list|backup|copy|delete`, and their MCP tools (delete needs confirm). level.dat is read with horizon-world's NBT. Co-Authored-By: Claude Opus 5.5 --- docs/launcher-commands.md | 43 +++++ launcher/Cargo.lock | 225 +++++++++++++++++++++++++- launcher/Cargo.toml | 6 + launcher/README.md | 7 + launcher/src/cli.rs | 100 ++++++++++++ launcher/src/cli_tools.rs | 1 + launcher/src/lib.rs | 1 + launcher/src/main.rs | 9 ++ launcher/src/worlds.rs | 270 +++++++++++++++++++++++++++++++ launcher/src/worlds/tests.rs | 157 ++++++++++++++++++ launcher/src/worlds_page.rs | 298 +++++++++++++++++++++++++++++++++++ 11 files changed, 1111 insertions(+), 6 deletions(-) create mode 100644 launcher/src/worlds.rs create mode 100644 launcher/src/worlds/tests.rs create mode 100644 launcher/src/worlds_page.rs diff --git a/docs/launcher-commands.md b/docs/launcher-commands.md index 6faaeed74..5d46c10cd 100644 --- a/docs/launcher-commands.md +++ b/docs/launcher-commands.md @@ -330,6 +330,49 @@ Keep an instance on one installed Horizon version, or "latest" to follow updates MCP: `instance_version`. +## `horizon-launcher worlds list` + +The worlds: name, mode, version, last played and size (the default). + + horizon-launcher worlds list + +- `--instance`: The instance (default: the selected one) + +MCP: `worlds_list`. + +## `horizon-launcher worlds backup` + +Zip a world into the instance's backups/ folder, as the game's Make Backup does. + + horizon-launcher worlds backup + +- `WORLD`: Its folder or name +- `--instance` + +MCP: `worlds_backup`. + +## `horizon-launcher worlds copy` + +Copy a world beside it, as " (1)". + + horizon-launcher worlds copy + +- `WORLD` +- `--instance` + +MCP: `worlds_copy`. + +## `horizon-launcher worlds delete` + +Move a world to the system's trash. + + horizon-launcher worlds delete + +- `WORLD` +- `--instance` + +MCP: `worlds_delete`, needs `confirm: true`. + ## `horizon-launcher modpack list` The imported packs and their coverage (the default). diff --git a/launcher/Cargo.lock b/launcher/Cargo.lock index dd9313df6..dbd21a37f 100644 --- a/launcher/Cargo.lock +++ b/launcher/Cargo.lock @@ -70,6 +70,15 @@ dependencies = [ "equator", ] +[[package]] +name = "android_system_properties" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc" +dependencies = [ + "libc", +] + [[package]] name = "anstream" version = "1.0.0" @@ -919,6 +928,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "chrono" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" +dependencies = [ + "iana-time-zone", + "num-traits", + "windows-link 0.2.1", +] + [[package]] name = "cipher" version = "0.4.4" @@ -981,6 +1001,15 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c133bc6a41be0d194c306b5506d15e6feeea7b1d6604bd3f8310dfb2ca96486" +[[package]] +name = "cobs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1" +dependencies = [ + "thiserror 2.0.21", +] + [[package]] name = "cocoa" version = "0.25.0" @@ -1635,6 +1664,18 @@ dependencies = [ "winreg", ] +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + [[package]] name = "encoding_rs" version = "0.8.42" @@ -2354,7 +2395,7 @@ dependencies = [ "wayland-protocols-plasma", "windows 0.61.3", "windows-core 0.61.2", - "windows-numerics", + "windows-numerics 0.2.0", "windows-registry 0.5.3", "x11-clipboard", "x11rb", @@ -2693,6 +2734,7 @@ dependencies = [ name = "horizon-launcher" version = "0.2.0" dependencies = [ + "chrono", "clap", "dirs 5.0.1", "flate2", @@ -2708,6 +2750,7 @@ dependencies = [ "horizon-release-sign", "horizon-telemetry", "horizon-theme", + "horizon-world", "image", "keyring", "objc2-app-kit", @@ -2720,6 +2763,7 @@ dependencies = [ "sha1", "sha2 0.10.9", "tar", + "trash", "ureq", "winresource", "zip", @@ -2801,6 +2845,21 @@ dependencies = [ name = "horizon-theme" version = "0.1.0" +[[package]] +name = "horizon-world" +version = "0.1.0" +dependencies = [ + "flate2", + "horizon-core", + "libm", + "lz4_flex", + "postcard", + "serde", + "serde_json", + "sha2 0.10.9", + "xxhash-rust", +] + [[package]] name = "http" version = "1.5.0" @@ -2907,6 +2966,30 @@ dependencies = [ "tracing", ] +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core 0.61.2", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "icu_collections" version = "2.3.0" @@ -3425,6 +3508,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "lz4_flex" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecbdfe44b1bd960b68170b417450a628c43f7cf56bb3c5317e61cb230ee7f226" + [[package]] name = "mac" version = "0.1.1" @@ -4263,6 +4352,18 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "postcard" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24" +dependencies = [ + "cobs", + "embedded-io 0.4.0", + "embedded-io 0.6.1", + "serde", +] + [[package]] name = "potential_utf" version = "0.1.6" @@ -6187,6 +6288,24 @@ dependencies = [ "once_cell", ] +[[package]] +name = "trash" +version = "5.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be89b3fe156965d29ac4f8522f3a640c655affdd9f21cb4f36857f0c92c00317" +dependencies = [ + "chrono", + "libc", + "log", + "objc2", + "objc2-foundation", + "once_cell", + "percent-encoding", + "scopeguard", + "urlencoding", + "windows 0.62.2", +] + [[package]] name = "try-lock" version = "0.2.5" @@ -6367,6 +6486,12 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + [[package]] name = "usvg" version = "0.45.1" @@ -6820,11 +6945,23 @@ version = "0.61.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" dependencies = [ - "windows-collections", + "windows-collections 0.2.0", "windows-core 0.61.2", - "windows-future", + "windows-future 0.2.1", "windows-link 0.1.3", - "windows-numerics", + "windows-numerics 0.2.0", +] + +[[package]] +name = "windows" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580" +dependencies = [ + "windows-collections 0.3.2", + "windows-core 0.62.2", + "windows-future 0.3.2", + "windows-numerics 0.3.1", ] [[package]] @@ -6837,7 +6974,7 @@ dependencies = [ "rayon", "thiserror 2.0.21", "windows 0.61.3", - "windows-future", + "windows-future 0.2.1", ] [[package]] @@ -6849,6 +6986,15 @@ dependencies = [ "windows-core 0.61.2", ] +[[package]] +name = "windows-collections" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610" +dependencies = [ + "windows-core 0.62.2", +] + [[package]] name = "windows-core" version = "0.57.0" @@ -6874,6 +7020,19 @@ dependencies = [ "windows-strings 0.4.2", ] +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement 0.60.2", + "windows-interface 0.59.3", + "windows-link 0.2.1", + "windows-result 0.4.1", + "windows-strings 0.5.1", +] + [[package]] name = "windows-future" version = "0.2.1" @@ -6882,7 +7041,18 @@ checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" dependencies = [ "windows-core 0.61.2", "windows-link 0.1.3", - "windows-threading", + "windows-threading 0.1.0", +] + +[[package]] +name = "windows-future" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb" +dependencies = [ + "windows-core 0.62.2", + "windows-link 0.2.1", + "windows-threading 0.2.1", ] [[package]] @@ -6951,6 +7121,16 @@ dependencies = [ "windows-link 0.1.3", ] +[[package]] +name = "windows-numerics" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26" +dependencies = [ + "windows-core 0.62.2", + "windows-link 0.2.1", +] + [[package]] name = "windows-registry" version = "0.4.0" @@ -6991,6 +7171,15 @@ dependencies = [ "windows-link 0.1.3", ] +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link 0.2.1", +] + [[package]] name = "windows-strings" version = "0.3.1" @@ -7009,6 +7198,15 @@ dependencies = [ "windows-link 0.1.3", ] +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link 0.2.1", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -7111,6 +7309,15 @@ dependencies = [ "windows-link 0.1.3", ] +[[package]] +name = "windows-threading" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37" +dependencies = [ + "windows-link 0.2.1", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -7423,6 +7630,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" +[[package]] +name = "xxhash-rust" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "550a2b930b62486a393c52d5c3b84bff264b28aa437ed64694d31e93b1757af7" + [[package]] name = "y4m" version = "0.8.0" diff --git a/launcher/Cargo.toml b/launcher/Cargo.toml index a97f128b8..57179380b 100644 --- a/launcher/Cargo.toml +++ b/launcher/Cargo.toml @@ -37,6 +37,12 @@ horizon-mods = { path = "../crates/horizon-mods", features = ["index"] } horizon-release-sign = { path = "../crates/horizon-release-sign" } # Opt-in data collection: the consent, the outbox and its upload (docs/telemetry.md). horizon-telemetry = { path = "../crates/horizon-telemetry" } +# level.dat and servers.dat (the worlds and server lists of instances) +horizon-world = { path = "../crates/horizon-world" } +# Deleting a world moves it to the system's trash +trash = "5" +# Backup names carry the local time, as vanilla's do +chrono = { version = "0.4", default-features = false, features = ["clock"] } # The session file's random name. getrandom = "0.3" # Players' heads on the Servers page, from the default skins in the player's own game files (already diff --git a/launcher/README.md b/launcher/README.md index ea4ebc39c..6a8fe7086 100644 --- a/launcher/README.md +++ b/launcher/README.md @@ -81,6 +81,11 @@ The opening, then Play ([clip](docs/opening.webm)): Open folder. Each instance plays the launcher's version, which follows updates, unless the Play page's version picker keeps it on another installed one (to keep an old world on the version it was made with); picking the version marked "follows updates" lets it follow again. +- **Worlds**: Home lists the selected instance's worlds (picture, mode, version, last played, + size). **Back up** zips one into the instance's `backups/` as the game's Make Backup does + (`_