From 66637220efc12e298a565d7d569c689f8442e1d0 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 15:13:58 +0100 Subject: [PATCH 01/27] Play the step sound of the block above the floor for the player Powder snow, lily pads, carpets, snow layers and similar blocks now sound like vanilla when walked on: inside blocks replace the floor's step, combination blocks play their own step with the floor's step muffled. --- .../examples/probe/scene_motion_probe.rs | 2 +- crates/horizon-client/src/game.rs | 6 +-- crates/horizon-client/src/game/remote.rs | 8 +-- crates/horizon-client/src/motion.rs | 51 ++++++++++++++++--- 4 files changed, 52 insertions(+), 15 deletions(-) diff --git a/crates/horizon-client/examples/probe/scene_motion_probe.rs b/crates/horizon-client/examples/probe/scene_motion_probe.rs index 21977eeab..67b2e1560 100644 --- a/crates/horizon-client/examples/probe/scene_motion_probe.rs +++ b/crates/horizon-client/examples/probe/scene_motion_probe.rs @@ -206,7 +206,7 @@ fn snapshot(out: &mut impl Write, player: &PlayerMotion) -> Result<()> { )), MotionEvent::Emission { state, - in_water: true, + muffled: true, .. } => Some(format!("muffled-step {}", state.0)), MotionEvent::BubbleColumnParticle { bubble, position } => Some(format!( diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 1d86fe990..f2f12d802 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -4349,13 +4349,11 @@ impl Game<'_> { for event in events { match event { MotionEvent::HurtSound(sound) => self.player_hurt_sound(sound, feet), - MotionEvent::Emission { - state, in_water, .. - } if !crouching => { + MotionEvent::Emission { state, muffled, .. } if !crouching => { let sounds = self.res.facts().get(state).sounds.clone(); // Entity.playStepSound: the block's step sound at 0.15 volume, // muffled under the swim sound in water. - let (volume, pitch) = if in_water { + let (volume, pitch) = if muffled { (sounds.volume * 0.05, sounds.pitch * 0.8) } else { (sounds.volume * 0.15, sounds.pitch) diff --git a/crates/horizon-client/src/game/remote.rs b/crates/horizon-client/src/game/remote.rs index 857f955da..f5365034a 100644 --- a/crates/horizon-client/src/game/remote.rs +++ b/crates/horizon-client/src/game/remote.rs @@ -3233,12 +3233,12 @@ impl Game<'_> { let feet = [player.position.x, player.position.y, player.position.z]; for event in events { match event { - horizon_client::motion::MotionEvent::Emission { - state, in_water, .. - } if !crouching => { + horizon_client::motion::MotionEvent::Emission { state, muffled, .. } + if !crouching => + { let sounds = self.res.facts().get(state).sounds.clone(); // Player.playStepSound: muffled under the swim sound in water. - let (volume, pitch) = if in_water { + let (volume, pitch) = if muffled { (sounds.volume * 0.05, sounds.pitch * 0.8) } else { (sounds.volume * 0.15, sounds.pitch) diff --git a/crates/horizon-client/src/motion.rs b/crates/horizon-client/src/motion.rs index 0bce8927c..1f788fb50 100644 --- a/crates/horizon-client/src/motion.rs +++ b/crates/horizon-client/src/motion.rs @@ -51,6 +51,10 @@ pub struct MotionResources { pub blocks: BoundMovementProperties, pub climbable: BTreeSet, pub fall_reset: BTreeSet, + /// `BlockTags.INSIDE_STEP_SOUND_BLOCKS`. + pub inside_step_sound: BTreeSet, + /// `BlockTags.COMBINATION_STEP_SOUND_BLOCKS`. + pub combination_step_sound: BTreeSet, pub landing: BlockLandingRegistry, pub health: crate::health::HealthResources, pub fluids: FluidResources, @@ -109,6 +113,8 @@ impl MotionResources { })?, climbable: tag("minecraft:climbable")?, fall_reset: tag("minecraft:fall_damage_resetting")?, + inside_step_sound: tag("minecraft:inside_step_sound_blocks")?, + combination_step_sound: tag("minecraft:combination_step_sound_blocks")?, }) } } @@ -136,11 +142,12 @@ pub enum MotionEvent { position: BlockPos, }, /// `Entity.walkingStepSound` on this block: `Player.playStepSound` - /// muffles it under a swim sound when `in_water`. + /// mutes it (`playMuffledStepSound`) under a swim sound in water or + /// under a combination block's own step. Emission { position: BlockPos, state: BlockStateId, - in_water: bool, + muffled: bool, }, /// `Entity.waterSwimSound`: `entity.player.swim`. Swim { @@ -1973,16 +1980,48 @@ impl MovementEmissionWorld for MotionWorld<'_, '_, '_> { fn in_water(&mut self) -> Result { Ok(self.player.fluids.was_touching_water) } - /// `Player.playStepSound`: in water a swim sound, then the step muffled. + /// `Player.playStepSound`: in water a swim sound, then the step muffled; + /// on land the step of an inside-sound block above the floor, or of a + /// combination block above it with the floor's step muffled. fn walking_step_sound(&mut self, position: BlockPos, state: BlockStateId) -> Result<()> { - let in_water = self.player.fluids.was_touching_water; - if in_water { + let muffled = self.player.fluids.was_touching_water; + if muffled { self.water_swim_sound()?; + } else { + // Entity.getPrimaryStepSoundBlockPos. + let above = BlockPos { + y: position.y + 1, + ..position + }; + let above_state = self.block(above); + let name = &self + .assets + .registry + .state(above_state) + .ok_or("missing scene state")? + .name; + let combination = self.resources.combination_step_sound.contains(name); + if combination || self.resources.inside_step_sound.contains(name) { + self.player.events.push(MotionEvent::Emission { + position: above, + state: above_state, + muffled: false, + }); + if combination { + // Entity.playCombinationStepSounds. + self.player.events.push(MotionEvent::Emission { + position, + state, + muffled: true, + }); + } + return Ok(()); + } } self.player.events.push(MotionEvent::Emission { position, state, - in_water, + muffled, }); Ok(()) } From 581dc08cf5be4da424c2e308e7185b1f979a6d79 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 15:15:43 +0100 Subject: [PATCH 02/27] Fire shot_crossbow and killed_by_arrow advancement triggers --- crates/horizon-client/src/advancements.rs | 37 ++++++++++++++++++- crates/horizon-client/src/arrows.rs | 3 ++ .../horizon-client/src/game/advancements.rs | 13 +++++++ crates/horizon-client/src/game/creatures.rs | 11 ++++++ crates/horizon-client/src/game/crossbow.rs | 7 ++++ 5 files changed, 70 insertions(+), 1 deletion(-) diff --git a/crates/horizon-client/src/advancements.rs b/crates/horizon-client/src/advancements.rs index 6706532b7..dda104281 100644 --- a/crates/horizon-client/src/advancements.rs +++ b/crates/horizon-client/src/advancements.rs @@ -4,7 +4,7 @@ //! conditions advancements use). use serde_json::Value; use std::{ - collections::{BTreeMap, HashMap}, + collections::{BTreeMap, BTreeSet, HashMap}, path::Path, }; @@ -703,6 +703,41 @@ pub fn entity(v: &Value, e: &EntityView, w: &dyn World, origin: [f64; 3]) -> boo } true } +/// `KilledByArrowTrigger.TriggerInstance.matches`: the weapon, each listed +/// victim condition matched by a distinct victim, and the count of entity types. +pub fn killed_by_arrow( + c: &Value, + me: &EntityView, + victims: &[EntityView], + weapon: Option<&ItemView>, + w: &dyn World, +) -> bool { + fn ctx<'a>(e: &'a EntityView, me: &EntityView) -> Entities<'a> { + Entities { + this: Some(e), + origin: me.position, + tool: None, + block_pos: None, + } + } + if !conditions(&c["player"], &ctx(me, me), w) { + return false; + } + if !c["fired_from_weapon"].is_null() + && !weapon.is_some_and(|it| item(&c["fired_from_weapon"], it, w)) + { + return false; + } + let mut left: Vec<&EntityView> = victims.iter().collect(); + for want in c["victims"].as_array().into_iter().flatten() { + let Some(i) = left.iter().position(|e| conditions(want, &ctx(e, me), w)) else { + return false; + }; + left.remove(i); + } + let kinds: BTreeSet<&str> = victims.iter().map(|e| e.kind.as_str()).collect(); + range_i(&c["unique_entity_types"], kinds.len() as i64) +} /// The entities a loot-style condition list may refer to. pub struct Entities<'a> { pub this: Option<&'a EntityView>, diff --git a/crates/horizon-client/src/arrows.rs b/crates/horizon-client/src/arrows.rs index 30b501011..c23e2ec71 100644 --- a/crates/horizon-client/src/arrows.rs +++ b/crates/horizon-client/src/arrows.rs @@ -155,6 +155,8 @@ pub struct ArrowState { pub pickup: Pickup, /// `pickupItemStack`: what picking the arrow up gives. pub pickup_item: crate::items::ItemStack, + /// `AbstractArrow.firedFromWeapon`: the crossbow or bow it was shot from. + pub fired_from_weapon: Option, pub no_physics: bool, pub pierce: u8, /// `Entity.remainingFireTicks`. @@ -197,6 +199,7 @@ impl ArrowState { last_state: None, pickup: Pickup::Disallowed, pickup_item: crate::items::ItemStack::new("minecraft:arrow", 1), + fired_from_weapon: None, no_physics: false, pierce: 0, fire_ticks: 0, diff --git a/crates/horizon-client/src/game/advancements.rs b/crates/horizon-client/src/game/advancements.rs index 0f76d0ca9..ed371417b 100644 --- a/crates/horizon-client/src/game/advancements.rs +++ b/crates/horizon-client/src/game/advancements.rs @@ -681,6 +681,19 @@ impl Game<'_> { adv::conditions(&c["player"], &pctx, w) && adv::conditions(&c[&key], &ectx, w) }); } + /// `KilledByArrowTrigger`: what the arrow killed and the weapon it came from. + pub(super) fn trigger_killed_by_arrow( + &mut self, + victims: &[EntityView], + weapon: Option<&ItemStack>, + ) { + let me = self.player_entity(); + let victims = victims.to_vec(); + let weapon = weapon.map(item_view); + self.trigger("minecraft:killed_by_arrow", move |c, w| { + adv::killed_by_arrow(c, &me, &victims, weapon.as_ref(), w) + }); + } /// A player condition plus one item (`item` key). pub(super) fn trigger_item(&mut self, name: &str, stack: &ItemStack) { let me = self.player_entity(); diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index 194256040..0efef9bc6 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -2111,6 +2111,17 @@ impl Game<'_> { .is_some_and(|m| m.damage(amount, source)); if p.owner == Some(Who::Player) { self.last_hurt_by_player.insert(id, self.lan_acting); + // AbstractArrow.onHitEntity: KILLED_BY_ARROW for a kill + // (piercing arrows are not modelled). + if hurt + && let Some(m) = self.mobs.iter().find(|m| m.id == id) + && !m.alive() + { + let victim = self.mob_entity(m); + let weapon = + p.arrow.as_ref().and_then(|a| a.fired_from_weapon.as_ref()); + self.trigger_killed_by_arrow(&[victim], weapon); + } } hurt } diff --git a/crates/horizon-client/src/game/crossbow.rs b/crates/horizon-client/src/game/crossbow.rs index 70ccba8d3..0e0df1a62 100644 --- a/crates/horizon-client/src/game/crossbow.rs +++ b/crates/horizon-client/src/game/crossbow.rs @@ -152,6 +152,7 @@ impl Game<'_> { }; let charged = std::mem::take(&mut bow.data_mut().charged); bow.tidy(); + let weapon = bow.clone(); let count = charged.len(); // getShootingPower: a rocket among them slows every shot. let power = if charged.iter().any(|s| &*s.item == FIREWORK_ROCKET) { @@ -204,6 +205,7 @@ impl Game<'_> { if let Some(a) = arrow.arrow.as_mut() { a.set_item(ammo); a.set_owner(Some(Who::Player)); + a.fired_from_weapon = Some(weapon.clone()); } arrow.shoot(&mut self.world.random, dir.to_array(), power, 1.0); self.creatures.projectiles.push(arrow); @@ -219,6 +221,11 @@ impl Game<'_> { .play("minecraft:item.crossbow.shoot", Some(eye), 1.0, pitch); self.damage_held(if rocket { 3 } else { 1 }); } + // CrossbowItem.performShooting: SHOT_CROSSBOW with the crossbow, which + // is an empty stack (no match) when the shots broke it. + if let Some(stack) = self.held().cloned() { + self.trigger_item("minecraft:shot_crossbow", &stack); + } } } From 6dcf4b3e8bbe734a1d906111405875ecee668579 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 18:45:43 +0100 Subject: [PATCH 03/27] Use the real local difficulty for the phantom spawn check The phantom spawn gate assumed a fixed effective difficulty of 2. Use the local difficulty at the player instead, so easy, hard, a long-played chunk and the moon phase change how often phantoms spawn. --- crates/horizon-client/src/game/stats.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/game/stats.rs b/crates/horizon-client/src/game/stats.rs index 7f64c6bb2..c653bf265 100644 --- a/crates/horizon-client/src/game/stats.rs +++ b/crates/horizon-client/src/game/stats.rs @@ -366,9 +366,10 @@ impl Game<'_> { if pos[1] < 63 || !self.can_see_sky(pos) { return; } - // DifficultyInstance.isHarderThan(random * 3) at normal difficulty. + // `getCurrentDifficultyAt(playerPos).isHarderThan(random * 3)`. + let difficulty = self.local_difficulty([position.x, position.y, position.z]); let r = &mut self.world.random; - if r.next_float() * 3.0 >= 2.0 { + if difficulty.effective <= r.next_float() * 3.0 { return; } if r.next_int_bound(since_rest.max(1)).unwrap_or(0) < 72000 { From 0b3e40f9d449923e4bb0d8d4de37211ad2306e07 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 19:15:28 +0100 Subject: [PATCH 04/27] Give a closed shulker its 20 covered armor --- crates/horizon-client/src/mobs.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/mobs.rs b/crates/horizon-client/src/mobs.rs index 00c21633e..5a13a588c 100644 --- a/crates/horizon-client/src/mobs.rs +++ b/crates/horizon-client/src/mobs.rs @@ -1730,9 +1730,15 @@ impl Mob { amount *= 0.75; } let (worn, worn_toughness) = self.worn_armor(); - if !source.bypasses_armor() && self.kind.armor + worn > 0.0 { + // Shulker.setRawPeekAmount: a closed shell adds the covered armor modifier. + let covered = if self.species() == Species::Shulker && self.extra.counter == 0 { + 20.0 + } else { + 0.0 + }; + if !source.bypasses_armor() && self.kind.armor + worn + covered > 0.0 { // CombatRules.getDamageAfterAbsorb - let armor = self.kind.armor + worn; + let armor = self.kind.armor + worn + covered; let toughness = 2.0 + (self.kind.armor_toughness + worn_toughness) / 4.0; let effective = (armor - amount / toughness).clamp(armor * 0.2, 20.0); let mut fraction = effective / 25.0; From 9dbd0a4bafb0dd09bfc9c9898d6971ca05a2e448 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 19:19:36 +0100 Subject: [PATCH 05/27] Make the strafing dragon charge its fireball only with a clear line of sight --- crates/horizon-client/src/game/dragon.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/horizon-client/src/game/dragon.rs b/crates/horizon-client/src/game/dragon.rs index fff03ef1c..43a3124d8 100644 --- a/crates/horizon-client/src/game/dragon.rs +++ b/crates/horizon-client/src/game/dragon.rs @@ -1374,7 +1374,16 @@ impl Game<'_> { } } let d2 = (pp.x - pos.x).powi(2) + (pp.y - pos.y).powi(2) + (pp.z - pos.z).powi(2); - if d2 < 4096.0 { + // Entity.hasLineOfSight: eye to eye (the dragon's eye is 0.85 of + // its 8 block height), blocks only. + let sees = d2 < 4096.0 && { + let eye = Vec3::new(pos.x, pos.y + 6.8, pos.z); + let target_eye = + tracked.map_or(pp.y + 1.62, |p| p.bounds.max_position().y - 0.18); + self.mob_world_base(&[]) + .line_of_sight(eye, Vec3::new(pp.x, target_eye, pp.z)) + }; + if sees { *charge += 1; let d = self.dragon.as_ref().expect("dragon"); let r = d.yaw.to_radians(); From 3b24aceb044f9caa07082b224994e931b395bfc9 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 19:21:53 +0100 Subject: [PATCH 06/27] Let /clone move work on overlapping regions --- crates/horizon-client/src/game/commands.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/horizon-client/src/game/commands.rs b/crates/horizon-client/src/game/commands.rs index 8f934ad8a..60e8aea59 100644 --- a/crates/horizon-client/src/game/commands.rs +++ b/crates/horizon-client/src/game/commands.rs @@ -2056,7 +2056,8 @@ impl Game<'_> { let dmax = [dest[0] + size[0], dest[1] + size[1], dest[2] + size[2]]; let overlap = (0..3).all(|i| dest[i] <= max[i] && dmax[i] >= min[i]); let moving = ctx.has("move"); - if !ctx.has("force") && overlap { + // Mode.canOverlap: only the normal mode refuses overlapping regions. + if !ctx.has("force") && !moving && overlap { return Err(err("commands.clone.overlap", &[])); } let area = (0..3).map(|i| i64::from(size[i] + 1)).product::(); From 8ca15ae2ca47df8857c611cde8c2208568a74101 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 19:23:47 +0100 Subject: [PATCH 07/27] Apply /xp, /clear and /spawnpoint to each target, not only the host --- crates/horizon-client/src/game/commands.rs | 171 +++++++++++++-------- 1 file changed, 103 insertions(+), 68 deletions(-) diff --git a/crates/horizon-client/src/game/commands.rs b/crates/horizon-client/src/game/commands.rs index 8f934ad8a..cc3398f90 100644 --- a/crates/horizon-client/src/game/commands.rs +++ b/crates/horizon-client/src/game/commands.rs @@ -2265,26 +2265,54 @@ impl Game<'_> { let levels = ctx.has("levels"); let unit = if levels { "levels" } else { "points" }; if ctx.has("query") { - let _ = self.entities(ctx, "target", true)?; - let e = &self.experience; - let value = if levels { - e.level - } else { - (e.progress * horizon_client::entities::Experience::needed(e.level) as f32) as i32 - }; + let target = self.entities(ctx, "target", true)?[0]; + // ExperienceCommand.queryExperience: the target's own level or points. + let value = self + .for_player(target, |g| { + let e = &g.experience; + if levels { + e.level + } else { + (e.progress * horizon_client::entities::Experience::needed(e.level) as f32) + as i32 + } + }) + .unwrap_or(0); self.system_message(Text::translate( &format!("commands.experience.query.{unit}"), - &[ - Text::literal(self.acting_player_name()), - Text::literal(value.to_string()), - ], + &[self.target_name(target), Text::literal(value.to_string())], )); return Ok(value); } let targets = self.entities(ctx, "target", true)?; let amount = Self::int(ctx, "amount").unwrap_or(0); - let op = if ctx.has("add") { "add" } else { "set" }; - if op == "add" { + let add = ctx.has("add"); + let op = if add { "add" } else { "set" }; + // Every target changes (a set of points can be refused for some). + let changed: Vec = targets + .iter() + .copied() + .filter(|&t| { + self.for_player(t, |g| g.change_experience(add, levels, amount)) == Some(true) + }) + .collect(); + if changed.is_empty() { + return Err(err("commands.experience.set.points.invalid", &[])); + } + let (key, who) = match changed[..] { + [only] => ("single", self.target_name(only)), + _ => ("multiple", Text::literal(changed.len().to_string())), + }; + self.feedback(Text::translate( + &format!("commands.experience.{op}.{unit}.success.{key}"), + &[Text::literal(amount.to_string()), who], + )); + Ok(changed.len() as i32) + } + /// ExperienceCommand's add and set on the player in place: false when + /// the points to set do not fit the level. + fn change_experience(&mut self, add: bool, levels: bool, amount: i32) -> bool { + if add { if levels { self.experience.level = (self.experience.level + amount).max(0); if self.experience.level == 0 && amount < 0 { @@ -2298,26 +2326,11 @@ impl Game<'_> { } else { let needed = horizon_client::entities::Experience::needed(self.experience.level); if amount > needed - 1 { - return Err(err("commands.experience.set.points.invalid", &[])); + return false; } self.experience.progress = amount as f32 / needed as f32; } - let key = format!( - "commands.experience.{op}.{unit}.success.{}", - if targets.len() == 1 { - "single" - } else { - "multiple" - } - ); - self.feedback(Text::translate( - &key, - &[ - Text::literal(amount.to_string()), - Text::literal(self.acting_player_name()), - ], - )); - Ok(targets.len() as i32) + true } fn cmd_gamerule(&mut self, ctx: &Context) -> R { let Some(name) = ctx.literals.get(1).cloned() else { @@ -2402,21 +2415,26 @@ impl Game<'_> { }; let yaw = ((rot[0] + 180.0).rem_euclid(360.0)) - 180.0; let pitch = rot[1].clamp(-90.0, 90.0); - // SetSpawnCommand: a forced point in the source's level. - if self.dim == Dim::Overworld { - self.spawn = Some(Vec3::new( - f64::from(pos[0]) + 0.5, - f64::from(pos[1]), - f64::from(pos[2]) + 0.5, - )); - self.respawn_config = None; - } else { - self.spawn = None; - self.respawn_config = Some(super::respawn_anchor::RespawnConfig { - dim: self.dim, - pos, - yaw, - forced: true, + // SetSpawnCommand: a forced point in the source's level, for each target. + let level = self.dim; + for &t in &targets { + self.for_player(t, |g| { + if level == Dim::Overworld { + g.spawn = Some(Vec3::new( + f64::from(pos[0]) + 0.5, + f64::from(pos[1]), + f64::from(pos[2]) + 0.5, + )); + g.respawn_config = None; + } else { + g.spawn = None; + g.respawn_config = Some(super::respawn_anchor::RespawnConfig { + dim: level, + pos, + yaw, + forced: true, + }); + } }); } let dim = Text::literal(self.dim.id()); @@ -2596,6 +2614,44 @@ impl Game<'_> { }, }; let max = Self::int(ctx, "maxCount").unwrap_or(-1); + let counting = max == 0; + // ClearInventoryCommands.clearInventory: each player on their own. + let mut removed = 0i32; + let mut found = Vec::new(); + for &t in &targets { + let n = self + .for_player(t, |g| g.clear_matching(&predicate, max)) + .unwrap_or(0); + removed += n; + if n != 0 { + found.push(t); + } + } + if removed == 0 { + return Err(if targets.len() == 1 { + CommandError::new(Text::translate( + "clear.failed.single", + &[self.target_name(targets[0])], + )) + } else { + err("clear.failed.multiple", &[&targets.len()]) + }); + } + let kind = if counting { "test" } else { "success" }; + let (key, who) = match found[..] { + [only] => ("single", self.target_name(only)), + _ => ("multiple", Text::literal(found.len().to_string())), + }; + self.feedback(Text::translate( + &format!("commands.clear.{kind}.{key}"), + &[Text::literal(removed.to_string()), who], + )); + Ok(removed) + } + /// Inventory.clearOrCountMatchingItems for the player in place: `max` + /// of the matching items go (all when negative, none and only counted + /// when 0). Returns how many matched. + fn clear_matching(&mut self, predicate: &ItemInput, max: i32) -> i32 { let counting = max == 0; // Inventory slots 0..40: main, armor feet to head, off hand; // then clearOrCountMatchingItems visits the crafting grid and carried stack. @@ -2611,10 +2667,7 @@ impl Game<'_> { }; let matching: Vec = all(self) .iter() - .map(|s| { - s.as_ref() - .is_some_and(|s| self.stack_matches(&predicate, s)) - }) + .map(|s| s.as_ref().is_some_and(|s| self.stack_matches(predicate, s))) .collect(); let mut slots: Vec<&mut Option> = Vec::new(); slots.extend(self.inventory.iter_mut()); @@ -2644,25 +2697,7 @@ impl Game<'_> { } } } - if removed == 0 { - return Err(if targets.len() == 1 { - CommandError::new(Text::translate( - "clear.failed.single", - &[Text::literal(self.acting_player_name())], - )) - } else { - err("clear.failed.multiple", &[&targets.len()]) - }); - } - let kind = if counting { "test" } else { "success" }; - self.feedback(Text::translate( - &format!("commands.clear.{kind}.single"), - &[ - Text::literal(removed.to_string()), - Text::literal(self.acting_player_name()), - ], - )); - Ok(removed) + removed } /// `PoiTypes`: the point of interest type of a block state. fn poi_type(&self, state: horizon_world::registry::BlockStateId) -> Option<&'static str> { From cb97c5496e127edc5287914d0ad63f974a0158b2 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 19:30:07 +0100 Subject: [PATCH 08/27] Raiders in a raid no longer count idle time twice as fast A raider's idle counter grew by 4 per tick while in a raid, so it dropped out of the raid after about 700 ticks instead of 1400 and could no longer be recruited sooner than in vanilla. Remove the extra tick added by the raid bookkeeping; the counter now grows by 3 like vanilla. --- crates/horizon-client/src/game/raids.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/crates/horizon-client/src/game/raids.rs b/crates/horizon-client/src/game/raids.rs index bedca5708..ce74e4e80 100644 --- a/crates/horizon-client/src/game/raids.rs +++ b/crates/horizon-client/src/game/raids.rs @@ -819,14 +819,11 @@ impl Game<'_> { if !alive { continue; } - // Raider.updateNoActionTime adds two per tick, and a raider - // fighting a player or golem in a raid is never idle. - if s.raid_id.is_some() { - m.ai.no_action_time = if target_player || target_golem { - 0 - } else { - m.ai.no_action_time + 1 - }; + // Raider.aiStep: a raider fighting a player or golem in a raid is + // never idle. The per-tick growth (+1 serverAiStep, +2 + // Raider.updateNoActionTime) is added by the mob's own step. + if s.raid_id.is_some() && (target_player || target_golem) { + m.ai.no_action_time = 0; } // Raider.aiStep: join the raid the raider stands in. if s.raid_id.is_none() From 575cef1d26a290eec7536f4a7fe081771d44a732 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 19:30:38 +0100 Subject: [PATCH 09/27] Let a vindicator named Johnny attack other raiders too Vanilla's Johnny goal targets any living entity that can be attacked. Horizon skipped pillagers, vindicators, witches, evokers, illusioners and ravagers, so Johnny left them alone. Remove that filter. --- crates/horizon-client/src/mobs/illager.rs | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/crates/horizon-client/src/mobs/illager.rs b/crates/horizon-client/src/mobs/illager.rs index 45ef076d3..c4693c182 100644 --- a/crates/horizon-client/src/mobs/illager.rs +++ b/crates/horizon-client/src/mobs/illager.rs @@ -13,18 +13,6 @@ use horizon_core::geometry::trig::Mth; use horizon_core::{geometry::Vec3, random::RandomSource}; use std::f32::consts::PI; -/// The species raiders do not fight (`Raider`'s allies). -fn raider(s: Species) -> bool { - matches!( - s, - Species::Pillager - | Species::Vindicator - | Species::Witch - | Species::Evoker - | Species::Illusioner - | Species::Ravager - ) -} fn targets(m: &mut Mob, villagers_seen: bool) { let mut hurt = HurtByTarget::new().alert(); hurt.ignore = vec![ @@ -78,10 +66,11 @@ pub fn register_vindicator(m: &mut Mob) { g.add(9, LookAtPlayer::new(3.0).probability(1.0)); g.add(10, LookAtPlayer::mobs(8.0)); targets(m, true); - // VindicatorJohnnyAttackGoal: a vindicator named Johnny attacks anything. + // VindicatorJohnnyAttackGoal: a vindicator named Johnny attacks any + // living entity, other raiders included. m.ai.targets.add( 4, - NearestTarget::new(Prey::Filter(|s| !raider(s.species)), true) + NearestTarget::new(Prey::Filter(|_| true), true) .interval(0) .when(|m, _| m.custom_name.as_deref() == Some("Johnny")), ); From 9bc05faf53c169c8ae19ac2ee8f118c576927a62 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 19:30:54 +0100 Subject: [PATCH 10/27] Tamed wolves heal twice the food's nutrition --- crates/horizon-client/src/game/creatures.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index d192a2b02..6f81189f6 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -2645,8 +2645,9 @@ impl Game<'_> { .items() .get(&item) .and_then(|i| i.food.as_ref()) - .map_or(2.0, |f| f.0 as f32); - // TamableAnimal.feed: playEatingSound, which wolves leave empty. + .map_or(2.0, |f| f.0 as f32 * 2.0); + // TamableAnimal.feed(.., 2.0F, 2.0F): heals twice the nutrition, + // then playEatingSound, which wolves leave empty. m.health = (m.health + heal).min(m.attrs.max_health); consume = true; } From de1e5f729226070d11aaca39c2a6d248797fc029 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 19:31:10 +0100 Subject: [PATCH 11/27] Spin the player arrow on a Nether map Vanilla's MapItemSavedData.calculateRotation gives the arrow a changing rotation in the Nether. The player marker used the yaw there too, so it never spun. --- crates/horizon-client/src/game/maps.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/horizon-client/src/game/maps.rs b/crates/horizon-client/src/game/maps.rs index 6da65c592..e87ba9cdd 100644 --- a/crates/horizon-client/src/game/maps.rs +++ b/crates/horizon-client/src/game/maps.rs @@ -774,9 +774,8 @@ impl Game<'_> { (d * 2.0 + 0.5) as i8 } }; - let y = f64::from(yaw); - let adjusted = if y < 0.0 { y - 8.0 } else { y + 8.0 }; - let rot = ((adjusted * 16.0 / 360.0) as i32 & 15) as u8; + // calculateRotation: the arrow spins in the Nether. + let rot = decoration_rotation(nether, game_time, f64::from(yaw)); let sprite = if inside { Some("map/decorations/player") } else if dx.abs() < 320.0 && dz.abs() < 320.0 { From 74dc389321d923a047e245c2e91cbbb999a2b59d Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 19:31:55 +0100 Subject: [PATCH 12/27] Keep the effect icons on screen over the pause menu, chat and other screens --- crates/horizon-client/src/game/potions.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/game/potions.rs b/crates/horizon-client/src/game/potions.rs index 13eae7d3e..cdf084377 100644 --- a/crates/horizon-client/src/game/potions.rs +++ b/crates/horizon-client/src/game/potions.rs @@ -780,9 +780,28 @@ impl Game<'_> { } } } - /// `Hud.extractEffects`: icons top-right, beneficial row then harmful row. + /// `Screen.showsActiveEffects`: the survival and creative inventories + /// draw their own effect list when `EffectsInInventory.canSeeEffects` + /// (32 or more pixels right of the screen). + fn screen_shows_active_effects(&self, batch: &HudBatch) -> bool { + let (ox, image_width) = match self.screen { + Screen::Inventory + if self.container.is_none() && self.craft_size == 2 && !self.mount_active() => + { + (self.inventory_origin(batch).0, 176) + } + Screen::Creative => ( + Self::creative_origin(batch).0, + horizon_client::creative::Creative::WIDTH as i32, + ), + _ => return false, + }; + batch.width as i32 - (ox as i32 + image_width + 2) >= 32 + } + /// `Hud.extractEffects`: icons top-right, beneficial row then harmful row; + /// every screen but the inventories keeps them. pub(super) fn draw_effect_icons(&self, batch: &mut HudBatch) { - if self.screen != Screen::Playing || self.potions.effects.list.is_empty() { + if self.potions.effects.list.is_empty() || self.screen_shows_active_effects(batch) { return; } let icons: Vec = self From 59bdb0059992dd7438a3cf0ee38f4fdcae495a7d Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 06:19:41 +0100 Subject: [PATCH 13/27] Husk, cave spider, wither skeleton, bee and pufferfish effects only come when the hit lands --- crates/horizon-client/src/game/creatures.rs | 12 +++++++++++ crates/horizon-client/src/game/lan_mobs.rs | 1 + crates/horizon-client/src/mobs.rs | 10 +++++++++ crates/horizon-client/src/mobs/ai.rs | 24 ++++++++++++++++++++- crates/horizon-client/src/mobs/aquatic.rs | 7 +++--- crates/horizon-client/src/mobs/bee.rs | 6 ++++-- 6 files changed, 53 insertions(+), 7 deletions(-) diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index 2bc40a7af..bd32153d5 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -961,6 +961,18 @@ impl Game<'_> { MobEvent::AttackPlayer(amount, from) => { self.mob_hits_player(amount, from, "minecraft:mob_attack"); } + // doHurtTarget: the effect only when hurtServer took damage. + MobEvent::AttackPlayerWithEffect { + amount, + from, + effect, + ticks, + amplifier, + } => { + if self.mob_hits_player(amount, from, "minecraft:mob_attack") { + self.give_player_effect(effect, ticks, amplifier); + } + } MobEvent::DamagePlayer { amount, from, kind } => { self.mob_hits_player(amount, from, kind); } diff --git a/crates/horizon-client/src/game/lan_mobs.rs b/crates/horizon-client/src/game/lan_mobs.rs index 6527f1015..f9d997452 100644 --- a/crates/horizon-client/src/game/lan_mobs.rs +++ b/crates/horizon-client/src/game/lan_mobs.rs @@ -65,6 +65,7 @@ pub(super) fn acts_on_player(e: &MobEvent) -> bool { matches!( e, MobEvent::AttackPlayer(..) + | MobEvent::AttackPlayerWithEffect { .. } | MobEvent::DamagePlayer { .. } | MobEvent::Push { target: Who::Player, diff --git a/crates/horizon-client/src/mobs.rs b/crates/horizon-client/src/mobs.rs index 2325c3f5b..ef93a2ff4 100644 --- a/crates/horizon-client/src/mobs.rs +++ b/crates/horizon-client/src/mobs.rs @@ -968,6 +968,16 @@ pub enum MobEvent { state: horizon_world::registry::BlockStateId, }, AttackPlayer(f32, [f64; 3]), + /// A melee hit whose effect comes only if the hit lands (husk hunger, + /// cave spider poison, wither skeleton wither, bee and pufferfish + /// poison): a shield-blocked hit gives nothing. + AttackPlayerWithEffect { + amount: f32, + from: [f64; 3], + effect: &'static str, + ticks: i32, + amplifier: i32, + }, /// Damage of a given type to the player (guardian lasers, thorns). DamagePlayer { amount: f32, diff --git a/crates/horizon-client/src/mobs/ai.rs b/crates/horizon-client/src/mobs/ai.rs index 26b94eeac..0bd93d151 100644 --- a/crates/horizon-client/src/mobs/ai.rs +++ b/crates/horizon-client/src/mobs/ai.rs @@ -1419,6 +1419,7 @@ pub fn do_hurt_target(m: &mut Mob, who: Who, cx: &mut Cx) { let mut amount = m.attrs.attack_damage; let from = [m.position.x, m.position.y, m.position.z]; let source = Damage::mob(m.id, from); + let first_event = cx.events.len(); match m.species() { // Difficulty NORMAL: cave spiders poison for 7 seconds. Species::CaveSpider if who == Who::Player => cx.events.push(MobEvent::EffectPlayer { @@ -1480,7 +1481,28 @@ pub fn do_hurt_target(m: &mut Mob, who: Who, cx: &mut Cx) { }); } match who { - Who::Player => cx.events.push(MobEvent::AttackPlayer(amount, from)), + // The effect picked above goes with the hit: it applies only when + // the player takes damage (a shield-blocked hit gives none). + Who::Player => { + let effect = cx.events[first_event..] + .iter() + .position(|e| matches!(e, MobEvent::EffectPlayer { .. })) + .map(|k| cx.events.remove(first_event + k)); + cx.events.push(match effect { + Some(MobEvent::EffectPlayer { + effect, + ticks, + amplifier, + }) => MobEvent::AttackPlayerWithEffect { + amount, + from, + effect, + ticks, + amplifier, + }, + _ => MobEvent::AttackPlayer(amount, from), + }); + } Who::Mob(id) => cx.events.push(MobEvent::AttackMob { target: id, amount, diff --git a/crates/horizon-client/src/mobs/aquatic.rs b/crates/horizon-client/src/mobs/aquatic.rs index f63a42239..3f42ddd31 100644 --- a/crates/horizon-client/src/mobs/aquatic.rs +++ b/crates/horizon-client/src/mobs/aquatic.rs @@ -244,11 +244,10 @@ pub fn ai_step(m: &mut Mob, w: &MobWorld, events: &mut Vec) { && m.ai.no_action_time % 10 == 0 { let amount = 1.0 + m.extra.size as f32; - events.push(MobEvent::AttackPlayer( + // Only when the sting hurt the player. + events.push(MobEvent::AttackPlayerWithEffect { amount, - [m.position.x, m.position.y, m.position.z], - )); - events.push(MobEvent::EffectPlayer { + from: [m.position.x, m.position.y, m.position.z], effect: "minecraft:poison", ticks: 60 * m.extra.size, amplifier: 0, diff --git a/crates/horizon-client/src/mobs/bee.rs b/crates/horizon-client/src/mobs/bee.rs index 27d8e7c84..330625fb0 100644 --- a/crates/horizon-client/src/mobs/bee.rs +++ b/crates/horizon-client/src/mobs/bee.rs @@ -322,9 +322,11 @@ pub fn sting(m: &mut Mob, who: Who, cx: &mut Cx) { let amount = (m.attrs.attack_damage as i32) as f32; match who { Who::Player => { - cx.events.push(MobEvent::AttackPlayer(amount, from)); + // Bee.doHurtTarget: the poison only when the sting hurt. let seconds = if cx.w.difficulty.hard { 18 } else { 10 }; - cx.events.push(MobEvent::EffectPlayer { + cx.events.push(MobEvent::AttackPlayerWithEffect { + amount, + from, effect: "minecraft:poison", ticks: seconds * 20, amplifier: 0, From 85f34393fe6438c0b5563496408907bcf429cae2 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 06:21:01 +0100 Subject: [PATCH 14/27] Save and load creative toolbars with the toolbar keys --- crates/horizon-client/src/game.rs | 12 +++++- .../src/game/creative_hotbar.rs | 39 +++++++++++++++++++ crates/horizon-client/src/hotbar.rs | 20 ++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 crates/horizon-client/src/game/creative_hotbar.rs diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 7699e83d7..a0e9e6b3c 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -34,6 +34,7 @@ mod consume; mod control; mod copper_golems; mod creaking; +mod creative_hotbar; mod creatures; mod crossbow; pub(crate) mod cushions; @@ -11471,7 +11472,7 @@ impl Game<'_> { | KeyCode::Digit9 if self.screen == Screen::Playing => { - self.selected = match key { + let slot = match key { KeyCode::Digit1 => 0, KeyCode::Digit2 => 1, KeyCode::Digit3 => 2, @@ -11482,6 +11483,15 @@ impl Game<'_> { KeyCode::Digit8 => 7, _ => 8, }; + // Minecraft.handleKeybinds: a creative player holding the load + // or save toolbar key loads or saves a toolbar instead (load + // first when both are held). + let load = self.mapped_key_down("key.loadToolbarActivator"); + if self.creative && (load || self.mapped_key_down("key.saveToolbarActivator")) { + self.hotbar_load_or_save(slot, load); + } else { + self.selected = slot; + } } _ => {} } diff --git a/crates/horizon-client/src/game/creative_hotbar.rs b/crates/horizon-client/src/game/creative_hotbar.rs new file mode 100644 index 000000000..81e5ad6c4 --- /dev/null +++ b/crates/horizon-client/src/game/creative_hotbar.rs @@ -0,0 +1,39 @@ +//! The creative toolbars, `hotbar.nbt` beside `options.txt`: hold the save or +//! load key and press a hotbar key (`Minecraft.handleKeybinds`). +use super::Game; +use horizon_client::{hotbar, keybinds, text::Text}; + +impl Game<'_> { + /// Whether the key bound to `mapping` is held. + pub(super) fn mapped_key_down(&self, mapping: &str) -> bool { + keybinds::key_code(self.settings.keys.get(mapping)) + .is_some_and(|k| self.physical_keys.contains(&k)) + } + + /// `CreativeModeInventoryScreen.handleHotbarLoadOrSave` for the hotbar key + /// `index`: load puts the saved row in the hotbar (the creative slot + /// packets follow from the inventory change), save stores the hotbar and + /// says so on the action bar. + pub(super) fn hotbar_load_or_save(&mut self, index: usize, load: bool) { + let path = Self::options_path().with_file_name("hotbar.nbt"); + let known = |id: &str| self.res.items().get(id).is_some(); + let mut rows = hotbar::load(&path, &known); + if load { + for (slot, stack) in rows[index].iter().enumerate() { + self.inventory[slot] = stack.clone(); + } + return; + } + rows[index] = self.inventory[..hotbar::SIZE].to_vec(); + let _ = hotbar::save(&path, &rows); + let key = |mapping: &str| keybinds::display_name(self.settings.keys.get(mapping)); + let message = Text::translate( + "inventory.hotbarSaved", + &[ + key("key.loadToolbarActivator"), + key(&format!("key.hotbar.{}", index + 1)), + ], + ); + self.titles.set_overlay(message, false); + } +} diff --git a/crates/horizon-client/src/hotbar.rs b/crates/horizon-client/src/hotbar.rs index a60f28287..dccae7560 100644 --- a/crates/horizon-client/src/hotbar.rs +++ b/crates/horizon-client/src/hotbar.rs @@ -119,3 +119,23 @@ pub fn load(path: &Path, known: &dyn Fn(&str) -> bool) -> Vec { _ => (0..GROUPS).map(|_| empty()).collect(), } } + +/// `HotbarManager.save`: the nine rows with the current data version, each +/// stack as `ItemStack.OPTIONAL_CODEC` writes it (an empty one is `{}`). +pub fn save(path: &Path, rows: &[Hotbar]) -> crate::Result<()> { + let mut entries = vec![( + JavaString::from("DataVersion"), + Tag::Int(horizon_world::DATA_VERSION), + )]; + for (i, row) in rows.iter().enumerate() { + let stacks = row.iter().map(|s| match s { + Some(s) => save::item_to_nbt(s), + None => Tag::compound(Vec::<(&str, Tag)>::new()), + }); + entries.push(( + JavaString::from(i.to_string().as_str()), + Tag::List(stacks.collect()), + )); + } + save::write_dat(path, Tag::compound(entries)) +} From 008c4f91cdd86513118c2001844550c29653674a Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 06:21:37 +0100 Subject: [PATCH 15/27] Treat single player as a local server for the tab list and F3 charts --- crates/horizon-client/src/game/debug_keys.rs | 5 +++-- crates/horizon-client/src/game/scoreboard.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/horizon-client/src/game/debug_keys.rs b/crates/horizon-client/src/game/debug_keys.rs index 16e7fc6e7..ff44c76dd 100644 --- a/crates/horizon-client/src/game/debug_keys.rs +++ b/crates/horizon-client/src/game/debug_keys.rs @@ -244,7 +244,8 @@ impl Game<'_> { if on { "visible" } else { "hidden" } ) }; - let remote = self.remote.is_some(); + // `DebugScreenOverlay`: the single-player variants for a local server. + let remote = !self.has_singleplayer_server(); let c = &self.debug_charts; [ format!( @@ -463,7 +464,7 @@ impl Game<'_> { height, self.settings.max_fps, 1000.0 / self.clock.rate(), - self.remote.is_some(), + !self.has_singleplayer_server(), ); draws.push(hud_layout::GuiDraw::Push(vec![hud_layout::PoseOp::Scale( scale, scale, diff --git a/crates/horizon-client/src/game/scoreboard.rs b/crates/horizon-client/src/game/scoreboard.rs index 72b3ab000..fd0b6ec98 100644 --- a/crates/horizon-client/src/game/scoreboard.rs +++ b/crates/horizon-client/src/game/scoreboard.rs @@ -677,7 +677,7 @@ impl Game<'_> { let objective = board.display_objective(sb::SLOT_LIST); let shown = tab_list::visible( key, - self.remote.is_none(), + self.has_singleplayer_server(), players.len(), objective.is_some(), ); From 4afb5748f2312a5f274cb5523893ab79693d5ca9 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 06:22:13 +0100 Subject: [PATCH 16/27] Let a player's axe hit disable the victim's shield --- crates/horizon-client/src/game/combat.rs | 4 ++++ crates/horizon-client/src/game/lan_pvp.rs | 13 ++++++++++++ crates/horizon-client/src/game/shield.rs | 24 ++++++++++++++++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/crates/horizon-client/src/game/combat.rs b/crates/horizon-client/src/game/combat.rs index 2d6b75902..f0395dda1 100644 --- a/crates/horizon-client/src/game/combat.rs +++ b/crates/horizon-client/src/game/combat.rs @@ -33,6 +33,10 @@ pub(super) struct CombatTracker { /// The projectile hitting the player now is another player's that /// `ServerPlayer.canHarmPlayer` refuses (the `pvp` rule, an ally). pub(super) refuse_player_hit: bool, + /// The player whose melee hit is landing on the player now: where they + /// stand and the seconds their weapon disables a shield for + /// (`getSecondsToDisableBlocking`). + pub(super) player_attacker: Option<([f64; 3], f32)>, /// The mob exploding now (`ServerExplosion.source`): its team's friendly /// fire decides whom the blast may hurt. pub(super) explosion_source: Option, diff --git a/crates/horizon-client/src/game/lan_pvp.rs b/crates/horizon-client/src/game/lan_pvp.rs index 65520221a..8e15bb1f3 100644 --- a/crates/horizon-client/src/game/lan_pvp.rs +++ b/crates/horizon-client/src/game/lan_pvp.rs @@ -40,6 +40,8 @@ pub(super) struct Strike { /// `Player.attack`'s `magicBoost > 0`: the enchantments added damage. magic: bool, from: [f64; 3], + /// `getSecondsToDisableBlocking` of the attacker's weapon. + disable_blocking: f32, sweep: Option<[f64; 3]>, /// `causeExtraKnockback`: its strength and direction (the attacker's /// yaw), and whether the hit is a sprinting knockback attack. @@ -122,6 +124,14 @@ impl Game<'_> { p.cause_food_exhaustion(0.1); } self.swing_arm(); + // LivingEntity.getSecondsToDisableBlocking: the held weapon's value, + // none while another item is in use. + let disable_blocking = if self.using.is_some() { + 0.0 + } else { + self.attack_item_info() + .map_or(0.0, |i| i.disable_blocking_seconds) + }; Some(Strike { attacker: self.lan_acting, amount, @@ -129,6 +139,7 @@ impl Game<'_> { crit, magic, from, + disable_blocking, sweep, knockback: (strength, xd, zd), knockback_attack, @@ -243,7 +254,9 @@ impl Game<'_> { // Player.attack: the hurt (with its knockback away from the // attacker), then causeExtraKnockback along the attacker's yaw. let land = |g: &mut Self| { + g.combat.player_attacker = Some((s.from, s.disable_blocking)); let hurt = g.mob_hits_player(s.amount, s.from, "minecraft:player_attack"); + g.combat.player_attacker = None; let (strength, xd, zd) = s.knockback; if hurt && strength > 0.0 { g.knock_back_player(f64::from(strength), xd, zd); diff --git a/crates/horizon-client/src/game/shield.rs b/crates/horizon-client/src/game/shield.rs index c4f7f98d1..e75dd56de 100644 --- a/crates/horizon-client/src/game/shield.rs +++ b/crates/horizon-client/src/game/shield.rs @@ -176,7 +176,14 @@ impl Game<'_> { if projectile { return; } - let Some(id) = attacker else { return }; + let Some(id) = attacker else { + // Another player's melee hit has no mob behind it. + if let Some((from, disable)) = self.combat.player_attacker { + let fully = outcome.blocked >= damage; + self.blocked_by_attacker(&component, [from[0], from[2]], fully, disable, at); + } + return; + }; let fully = outcome.blocked >= damage; let Some(m) = self.mobs.iter().find(|m| m.id == id) else { return; @@ -214,6 +221,21 @@ impl Game<'_> { let _ = self.handle_mob_events(events); return; } + self.blocked_by_attacker(&component, [mx, mz], fully, disable, at); + } + + /// What a blocked melee hit does to the defender once the shield took + /// it: `LivingEntity.blockedByItem` knocks them back unless fully + /// blocked, then `Player.blockUsingItem` disables the shield. + fn blocked_by_attacker( + &mut self, + component: &horizon_client::items::BlocksAttacks, + attacker: [f64; 2], + fully: bool, + disable: f32, + at: Option<[f64; 3]>, + ) { + let [mx, mz] = attacker; // LivingEntity.blockedByItem: defender.knockback(0.5, defender - attacker), // which moves the defender along -(xd, zd). if !fully && let Some(p) = self.player.as_mut() { From 0cd3410a2db5a69d146b3a18631a73f99d9d21cb Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 06:23:01 +0100 Subject: [PATCH 17/27] Squeeze hotbar slots that gain items and draw the bundle fullness bar --- crates/horizon-client/src/bundle.rs | 11 +++++++++++ crates/horizon-client/src/game.rs | 18 +++++++++++++++--- crates/horizon-client/src/game/remote.rs | 18 ++++++++++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/crates/horizon-client/src/bundle.rs b/crates/horizon-client/src/bundle.rs index 948e2f4a9..49d29d5f9 100644 --- a/crates/horizon-client/src/bundle.rs +++ b/crates/horizon-client/src/bundle.rs @@ -211,6 +211,17 @@ impl Contents { self.weight.n >= self.weight.d } + /// `BundleItem.isBarVisible`, `getBarWidth` and `getBarColor`: the fullness bar + /// (width, RGB), blue until the bundle is full, then red. + pub fn bar(&self) -> Option<(i32, u32)> { + if self.weight.n <= 0 { + return None; + } + let width = (1 + self.weight.n * 12 / self.weight.d).min(13) as i32; + let color = if self.is_full() { 0xFF5454 } else { 0x7087FF }; + Some((width, color)) + } + /// `toImmutable`, written back into the bundle's component. pub fn store(self, bundle: &mut ItemStack) { let data = bundle.data_mut(); diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 7699e83d7..d30cba2bf 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -1431,6 +1431,9 @@ struct Game<'a> { armor: [Option; 4], /// The off hand (Inventory slot 40, saved as slot 150; menu slot 504 here). offhand: Option, + /// `ItemStack.popTime` of the nine hotbar stacks, then the off hand: set to 5 + /// when a slot gains items, counted down each tick. + hotbar_pop: [u8; 10], /// The hand an item use acts with (`InteractionHand`): the off hand only /// for its turn in `use_item` and while its item is being used. hand: Hand, @@ -5308,7 +5311,10 @@ impl Game<'_> { let decorations = hud_overlays::ItemDecorations { count: stack.count, count_text, - bar: hud_overlays::damage_bar(stack.damage as i32, max_damage), + // BundleItem overrides the bar with its fullness. + bar: horizon_client::bundle::Contents::of(self.res.items(), stack) + .map(|c| c.bar()) + .unwrap_or_else(|| hud_overlays::damage_bar(stack.damage as i32, max_damage)), cooldown: self.cooldowns.percent(&cooldown, partial), }; let mut draws = vec![hud_layout::GuiDraw::Push(vec![ @@ -5405,12 +5411,17 @@ impl Game<'_> { hud_layout::paint(&mut batch, &self.gui.atlas, &draws); } if !spectator { + let partial = self.clock.fraction() as f32; let inputs = hud_layout::HotbarInputs { selected: self.selected as i32, right_handed: !self.settings.main_hand_left, offhand: self.offhand.is_some(), - slots: std::array::from_fn(|i| self.inventory[i].as_ref().map(|_| 0.0)), - offhand_pop: 0.0, + slots: std::array::from_fn(|i| { + self.inventory[i] + .as_ref() + .map(|_| (f32::from(self.hotbar_pop[i]) - partial).max(0.0)) + }), + offhand_pop: (f32::from(self.hotbar_pop[9]) - partial).max(0.0), attack: (indicator == 2).then_some(strength), }; let draws = hud_layout::hotbar(wi, hi, &inputs); @@ -12941,6 +12952,7 @@ impl<'a> Game<'a> { title: None, armor: [None, None, None, None], offhand: None, + hotbar_pop: [0; 10], hand: Hand::Main, shield_cooldown: 0, cooldowns: Default::default(), diff --git a/crates/horizon-client/src/game/remote.rs b/crates/horizon-client/src/game/remote.rs index 77e143f9a..20832879f 100644 --- a/crates/horizon-client/src/game/remote.rs +++ b/crates/horizon-client/src/game/remote.rs @@ -2358,6 +2358,20 @@ impl Game<'_> { r.state_id = p.state; } let stack = self.to_stack(&p.item); + // ClientPacketListener.handleContainerSetSlot: a hotbar slot that + // gains items squeezes for 5 ticks. + if p.container == 0 + && (36..=45).contains(&p.slot) + && let Some(new) = &stack + { + let (pop, old) = match p.slot { + 45 => (9, self.offhand.as_ref()), + s => (s as usize - 36, self.inventory[s as usize - 36].as_ref()), + }; + if old.is_none_or(|old| old.count < new.count) { + self.hotbar_pop[pop] = 5; + } + } self.set_menu_slot(p.container, i32::from(p.slot), stack); self.remote_synced(); } @@ -3177,6 +3191,10 @@ impl Game<'_> { // server says the entry ended. `onCooldownEnded` is the plain // ItemCooldowns' no-op on a client. self.cooldowns.tick(); + // Inventory.tick's ItemStack.inventoryTick: the pop time runs down. + for pop in &mut self.hotbar_pop { + *pop = pop.saturating_sub(1); + } // Leaving a slot clears its bundle's selection here and on the server. self.tick_bundle_hover(); // Options.broadcastOptions: a changed render distance or Chat option From 1f98f3ca89d04dc6046ed5c2c4717c96496593ca Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 06:23:22 +0100 Subject: [PATCH 18/27] Open the Leave Bed chat screen while the player sleeps --- crates/horizon-client/src/game.rs | 4 +- crates/horizon-client/src/game/chat.rs | 77 +++++++++++++++++++++++- crates/horizon-client/src/game/titles.rs | 1 + 3 files changed, 80 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 7699e83d7..db9a96d01 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -10333,7 +10333,9 @@ impl Game<'_> { fn tick_sleep(&mut self) { self.sleep_timer = tick_sleep_timer(self.sleep_timer, self.sleeping.is_some()); if let Some(head) = self.sleeping { - if self.keys.contains(&KeyCode::ShiftLeft) + // Vanilla has no Shift wake-up: the chat screen's capitals must + // not get the sleeper up. + if (self.screen != Screen::Chat && self.keys.contains(&KeyCode::ShiftLeft)) || self .player .as_ref() diff --git a/crates/horizon-client/src/game/chat.rs b/crates/horizon-client/src/game/chat.rs index 03174c009..9a87f2d74 100644 --- a/crates/horizon-client/src/game/chat.rs +++ b/crates/horizon-client/src/game/chat.rs @@ -81,6 +81,8 @@ pub struct UiState { pub chat_screen: Option, /// When the chat screen opened (its input took the focus: the cursor blink). pub chat_opened: Option, + /// The chat screen is `InBedChatScreen`: the sleeper's, with a Leave Bed button. + pub in_bed_chat: bool, pub registries: Registries, pub rules: GameRules, pub clock: WorldClock, @@ -440,6 +442,12 @@ impl Game<'_> { self.capture(false); } pub(super) fn close_chat(&mut self) { + // InBedChatScreen.onClose: leaving the screen means getting up; the + // screen goes once the player has woken (`tick_in_bed_chat`). + if self.ui.in_bed_chat && self.sleeping.is_some() { + self.wake_up(); + return; + } self.ui.chat_screen = None; self.ui.chat.reset_scroll(); if self.screen == Screen::Chat { @@ -447,6 +455,35 @@ impl Game<'_> { self.capture(true); } } + /// `Gui.tick`: a sleeper gets `InBedChatScreen`; when the player has + /// woken (`onPlayerWokeUp`) it closes, or turns into the plain chat + /// screen if something was typed. + pub(super) fn tick_in_bed_chat(&mut self) { + if self.screen != Screen::Chat { + self.ui.in_bed_chat = false; + } + if self.ui.in_bed_chat { + if self.sleeping.is_none() { + self.ui.in_bed_chat = false; + let text = self + .ui + .chat_screen + .as_ref() + .map_or_else(String::new, |s| s.value().to_owned()); + self.close_chat(); + if !text.is_empty() { + self.open_chat(&text); + } + } + } else if self.sleeping.is_some() && self.screen == Screen::Playing { + self.open_chat(""); + self.ui.in_bed_chat = self.screen == Screen::Chat; + } + } + /// The Leave Bed button of `InBedChatScreen`: its bounds. + fn leave_bed_button(width: f32, height: f32) -> (i32, i32, i32, i32) { + (width as i32 / 2 - 100, height as i32 - 40, 200, 20) + } /// `Minecraft.computeChatAbilities` from the Chat option. pub(super) fn chat_abilities(&self) -> ChatAbilities { ChatAbilities::new(ChatVisibility::from_option(self.settings.chat_visibility)) @@ -559,7 +596,15 @@ impl Game<'_> { match screen.key(&m, &c, &self.ui.chat.recent, key, shift, ctrl) { ChatAction::Close => self.close_chat(), ChatAction::Submit(message) => { - self.close_chat(); + // InBedChatScreen sends without closing (`closeOnSubmit` is + // false): the box empties and the screen stays. + if self.ui.in_bed_chat && self.sleeping.is_some() { + screen.suggest_command(&m, &c, ""); + self.ui.chat.reset_scroll(); + self.ui.chat_screen = Some(screen); + } else { + self.close_chat(); + } if !message.is_empty() { self.handle_chat_input(&message); } @@ -675,6 +720,16 @@ impl Game<'_> { dispatcher: chat_tree(&self.remote, &self.mods), registries: &self.ui.registries, }; + if self.ui.in_bed_chat && self.sleeping.is_some() { + let width = self.renderer.as_ref().map_or(1280.0, |r| { + HudBatch::new([r.config.width, r.config.height]).width + }); + let (x, y, w, h) = Self::leave_bed_button(width, height); + if horizon_client::screen_draw::inside((cursor.0 as i32, cursor.1 as i32), x, y, w, h) { + self.wake_up(); + return; + } + } if let Some(screen) = self.ui.chat_screen.as_mut() { if screen.click(&m, &c, cursor.0 as f64, cursor.1 as f64) { return; @@ -737,6 +792,26 @@ impl Game<'_> { let draws = screen.draw(&m, mouse, blink, background); horizon_client::screen_draw::paint(batch, &self.gui.atlas, &draws); self.ui.chat_screen = Some(screen); + if self.ui.in_bed_chat && self.sleeping.is_some() { + let (x, y, w, h) = Self::leave_bed_button(batch.width, batch.height); + let label = Text::literal(horizon_client::lang::get_or( + "multiplayer.stopSleeping", + "Leave Bed", + )); + let mut button = Vec::new(); + horizon_client::screen_draw::button( + &mut button, + &m, + &label, + x, + y, + w, + h, + true, + horizon_client::screen_draw::inside(mouse, x, y, w, h), + ); + horizon_client::screen_draw::paint(batch, &self.gui.atlas, &button); + } // The hovered message part's tooltip, one row per line of its text. if let Some(hover) = self.ui.chat.hover_at( &self.gui.atlas.font, diff --git a/crates/horizon-client/src/game/titles.rs b/crates/horizon-client/src/game/titles.rs index 9bb000314..daf2e9f5d 100644 --- a/crates/horizon-client/src/game/titles.rs +++ b/crates/horizon-client/src/game/titles.rs @@ -60,6 +60,7 @@ impl Game<'_> { /// The title, action bar and selected-item parts of `Hud.tick`. pub(super) fn tick_hud(&mut self) { self.titles.tick(); + self.tick_in_bed_chat(); // `MinecraftServer.isCurrentlySaving` of single player's server. let saving = self .integrated From b6c77e12f3a0df7e61039030d0af48397d643163 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 06:23:43 +0100 Subject: [PATCH 19/27] Hide invisible guests in the host window --- crates/horizon-client/src/game/lan.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/horizon-client/src/game/lan.rs b/crates/horizon-client/src/game/lan.rs index 28ec3fe8a..c81e8eb1a 100644 --- a/crates/horizon-client/src/game/lan.rs +++ b/crates/horizon-client/src/game/lan.rs @@ -1498,6 +1498,14 @@ impl Game<'_> { .filter_map(|e| super::client_ambient::effect_particle(e.id, e.ambient)) .collect(); m.extra.effect_ambient = visible().all(|e| e.ambient); + // Entity.isInvisible: the invisibility effect hides the body (the + // model pass, the name tag rules and `trader::is_invisible` read it). + m.extra.effects.retain(|e| e.0 != "minecraft:invisibility"); + if let Some(e) = g.effects.get("invisibility") { + m.extra + .effects + .push(("minecraft:invisibility", e.duration, e.amplifier)); + } // Lying in its bed (LivingEntity.getBedOrientation). m.extra.ints[1] = g.bed.map_or(0, |b| self.bed_facing(b)); // LivingEntity.updateSwingTime: the arm swing lan_swings started. From 71b2f110ebd8f3e6453821ef202966f2b895af4c Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 06:23:59 +0100 Subject: [PATCH 20/27] Show the account name on the book signing screen --- crates/horizon-client/src/game/books.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/horizon-client/src/game/books.rs b/crates/horizon-client/src/game/books.rs index 2f38dffd9..5c158536d 100644 --- a/crates/horizon-client/src/game/books.rs +++ b/crates/horizon-client/src/game/books.rs @@ -1077,7 +1077,12 @@ impl Game<'_> { BLACK, ); } - let by = tr("book.byAuthor", "by %1$s").replace("%1$s", super::chat::PLAYER_NAME); + // BookSignScreen: `owner.getName()`, the account's name on a server. + let owner = self + .remote + .as_ref() + .map_or(super::chat::PLAYER_NAME, |r| r.profile_name.as_str()); + let by = tr("book.byAuthor", "by %1$s").replace("%1$s", owner); let tw = HudBatch::text_width(atlas, &by); batch.text( atlas, From 62556429dcee4673e443015fcaa5bbc91abb9743 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 06:30:09 +0100 Subject: [PATCH 21/27] Add the four missing options to the Chat page --- crates/horizon-client/src/options_ui.rs | 33 ++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/crates/horizon-client/src/options_ui.rs b/crates/horizon-client/src/options_ui.rs index a40d11258..4e372e75c 100644 --- a/crates/horizon-client/src/options_ui.rs +++ b/crates/horizon-client/src/options_ui.rs @@ -56,6 +56,7 @@ pub enum Opt { ChatVisibility, ChatColors, ChatLinks, + ChatLinksPrompt, ChatOpacity, TextBackgroundOpacity, ChatScale, @@ -64,7 +65,10 @@ pub enum Opt { ChatHeightUnfocused, ChatLineSpacing, AutoSuggestions, + HideMatchedNames, ReducedDebugInfo, + OnlySecureChat, + SaveChatDrafts, HighContrast, ShowSubtitles, MusicFrequency, @@ -167,6 +171,11 @@ impl Opt { Opt::Narrator | Opt::NarratorHotkey | Opt::ChatDelay + // Stored, but there are no blocked players, signed chat or + // chat drafts yet. + | Opt::HideMatchedNames + | Opt::OnlySecureChat + | Opt::SaveChatDrafts | Opt::DistortionEffects | Opt::GlintSpeed | Opt::GlintStrength @@ -184,6 +193,10 @@ impl Opt { Opt::Narrator => "narrator", Opt::TextBackground => "backgroundForChatOnly", Opt::ChatDelay => "chatDelay", + Opt::ChatLinksPrompt => "chatLinksPrompt", + Opt::HideMatchedNames => "hideMatchedNames", + Opt::OnlySecureChat => "onlyShowSecureChat", + Opt::SaveChatDrafts => "saveChatDrafts", Opt::DistortionEffects => "screenEffectScale", Opt::FovEffects => "fovEffectScale", Opt::DarknessPulsing => "darknessEffectScale", @@ -243,6 +256,7 @@ impl Opt { Opt::ChatVisibility => "options.chat.visibility", Opt::ChatColors => "options.chat.color", Opt::ChatLinks => "options.chat.links", + Opt::ChatLinksPrompt => "options.chat.links.prompt", Opt::ChatOpacity => "options.chat.opacity", Opt::TextBackgroundOpacity => "options.accessibility.text_background_opacity", Opt::ChatScale => "options.chat.scale", @@ -251,6 +265,9 @@ impl Opt { Opt::ChatHeightUnfocused => "options.chat.height.unfocused", Opt::ChatLineSpacing => "options.chat.line_spacing", Opt::AutoSuggestions => "options.autoSuggestCommands", + Opt::HideMatchedNames => "options.hideMatchedNames", + Opt::OnlySecureChat => "options.onlyShowSecureChat", + Opt::SaveChatDrafts => "options.chat.drafts", Opt::ReducedDebugInfo => "options.reducedDebugInfo", Opt::HighContrast => "options.accessibility.high_contrast", Opt::ShowSubtitles => "options.showSubtitles", @@ -524,6 +541,10 @@ impl Opt { Opt::HideLightningFlashes => on_off(s.file.bool("hideLightningFlashes")), Opt::MonochromeLogo => on_off(s.file.bool("darkMojangStudiosBackground")), Opt::HideSplashTexts => on_off(s.file.bool("hideSplashTexts")), + Opt::ChatLinksPrompt + | Opt::HideMatchedNames + | Opt::OnlySecureChat + | Opt::SaveChatDrafts => on_off(s.file.bool(self.file_key().unwrap())), Opt::NarratorHotkey => on_off(s.file.bool("narratorHotkey")), Opt::RotateWithMinecarts => on_off(s.file.bool("rotateWithMinecart")), Opt::HighContrastBlockOutlines => on_off(s.file.bool("highContrastBlockOutline")), @@ -718,7 +739,13 @@ impl Opt { value + 1 }; } - Opt::TextBackground | Opt::HideLightningFlashes | Opt::HideSplashTexts => { + Opt::TextBackground + | Opt::HideLightningFlashes + | Opt::HideSplashTexts + | Opt::ChatLinksPrompt + | Opt::HideMatchedNames + | Opt::OnlySecureChat + | Opt::SaveChatDrafts => { let key = self.file_key().unwrap(); s.file .set(key, crate::options_file::V::Bool(!s.file.bool(key))); @@ -1507,6 +1534,7 @@ impl OptionsUi { Opt::ChatVisibility, Opt::ChatColors, Opt::ChatLinks, + Opt::ChatLinksPrompt, Opt::ChatOpacity, Opt::TextBackgroundOpacity, Opt::ChatScale, @@ -1515,7 +1543,10 @@ impl OptionsUi { Opt::ChatHeightFocused, Opt::ChatHeightUnfocused, Opt::AutoSuggestions, + Opt::HideMatchedNames, Opt::ReducedDebugInfo, + Opt::OnlySecureChat, + Opt::SaveChatDrafts, ]), Page::Accessibility => { let mut rows = vec![Row::Buttons( From 2c0d3c1a86e51f95badc0f34783f695b5c31b017 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 06:30:46 +0100 Subject: [PATCH 22/27] Chat wheel counts right Shift, durability line is translated --- crates/horizon-client/src/game/chat.rs | 3 ++- crates/horizon-client/src/game/stations.rs | 18 +++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/crates/horizon-client/src/game/chat.rs b/crates/horizon-client/src/game/chat.rs index 03174c009..f4078ffc5 100644 --- a/crates/horizon-client/src/game/chat.rs +++ b/crates/horizon-client/src/game/chat.rs @@ -661,7 +661,8 @@ impl Game<'_> { { return; } - let shift = self.keys.contains(&KeyCode::ShiftLeft); + // ChatScreen.mouseScrolled: `hasShiftDown`, either Shift key. + let shift = self.has_shift_down(); let amount = amount.clamp(-1.0, 1.0) * if shift { 1.0 } else { 7.0 }; self.ui.chat.scroll_by(amount as i32, true); } diff --git a/crates/horizon-client/src/game/stations.rs b/crates/horizon-client/src/game/stations.rs index 361879d2e..43eb1ca6c 100644 --- a/crates/horizon-client/src/game/stations.rs +++ b/crates/horizon-client/src/game/stations.rs @@ -2023,15 +2023,19 @@ impl Game<'_> { && stack.damage > 0 && advanced { - push( - &mut lines, - format!( - "Durability: {} / {}", - info.max_damage - stack.damage, - info.max_damage + // `item.durability`, in the selected language. + lines.push(( + horizon_client::text::Text::translate( + "item.durability", + &[ + horizon_client::text::Text::literal( + (info.max_damage - stack.damage).to_string(), + ), + horizon_client::text::Text::literal(info.max_damage.to_string()), + ], ), u32::MAX, - ); + )); } // ItemStack.addDetailsToTooltipTail: with advanced tooltips the item id // and how many components the stack has. From 581828bf9419573b064976f704c969a279b742e6 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 06:30:47 +0100 Subject: [PATCH 23/27] Show the smithing template lines in item tooltips --- crates/horizon-client/src/game/stations.rs | 5 ++ crates/horizon-client/src/item_tooltip.rs | 60 +++++++++++++--------- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/crates/horizon-client/src/game/stations.rs b/crates/horizon-client/src/game/stations.rs index 361879d2e..47ae04472 100644 --- a/crates/horizon-client/src/game/stations.rs +++ b/crates/horizon-client/src/game/stations.rs @@ -1768,6 +1768,11 @@ impl Game<'_> { }; let gray = rgba(170, 170, 170, 255); let item_info = self.res.items().get(&stack.item); + // SmithingTemplateItem.appendHoverText: `Item.appendHoverText` comes + // before the components. + for (text, c) in horizon_client::item_tooltip::smithing_template_lines(stack, &translate) { + push(&mut lines, text, c); + } // InstrumentComponent.addToTooltip. if let Some(text) = horizon_client::item_tooltip::instrument_line(stack, &display, &translate) diff --git a/crates/horizon-client/src/item_tooltip.rs b/crates/horizon-client/src/item_tooltip.rs index 63a19b114..ce4fc352d 100644 --- a/crates/horizon-client/src/item_tooltip.rs +++ b/crates/horizon-client/src/item_tooltip.rs @@ -484,6 +484,37 @@ pub fn component_count(stack: &ItemStack, info: Option<&ItemInfo>) -> usize { keys.len() } +/// `SmithingTemplateItem.appendHoverText`: the template's kind, what it applies to +/// and its ingredients (gray titles over blue descriptions); none for other items. +pub fn smithing_template_lines( + stack: &ItemStack, + translate: &dyn Fn(&str) -> Option, +) -> Vec<(String, u32)> { + let path = stack.item.trim_start_matches("minecraft:"); + if !path.ends_with("_smithing_template") { + return Vec::new(); + } + let text = |key: &str| translate(key).unwrap_or_else(|| key.to_owned()); + let kind = if path == "netherite_upgrade_smithing_template" { + "netherite_upgrade" + } else { + "armor_trim" + }; + let (title, description) = (rgba(170, 170, 170, 255), rgba(85, 85, 255, 255)); + let described = |what: &str| { + let key = format!("item.minecraft.smithing_template.{kind}.{what}"); + (format!(" {}", text(&key)), description) + }; + vec![ + (text("item.minecraft.smithing_template"), title), + (String::new(), u32::MAX), + (text("item.minecraft.smithing_template.applies_to"), title), + described("applies_to"), + (text("item.minecraft.smithing_template.ingredients"), title), + described("ingredients"), + ] +} + /// The lines of `stack` below its name that its components give, in /// `ItemStack.addDetailsToTooltip` order. pub fn detail_lines( @@ -494,30 +525,11 @@ pub fn detail_lines( let text = |key: &str| translate(key).unwrap_or_else(|| key.to_owned()); let path = stack.item.trim_start_matches("minecraft:"); let mut lines = Vec::new(); - // SmithingTemplateItem.appendHoverText. - if path.ends_with("_smithing_template") { - let kind = if path == "netherite_upgrade_smithing_template" { - "netherite_upgrade" - } else { - "armor_trim" - }; - lines.push(text("item.minecraft.smithing_template")); - lines.push(String::new()); - lines.push(text("item.minecraft.smithing_template.applies_to")); - lines.push(format!( - " {}", - text(&format!( - "item.minecraft.smithing_template.{kind}.applies_to" - )) - )); - lines.push(text("item.minecraft.smithing_template.ingredients")); - lines.push(format!( - " {}", - text(&format!( - "item.minecraft.smithing_template.{kind}.ingredients" - )) - )); - } + lines.extend( + smithing_template_lines(stack, translate) + .into_iter() + .map(|l| l.0), + ); let display = TooltipDisplay::for_stack(stack); lines.extend(bees_line(stack, &display, translate)); lines.extend(honey_line(stack, &display, translate)); From dca3bb89fe37a9a24b815eb75902767fac4e8d80 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 06:32:01 +0100 Subject: [PATCH 24/27] Show the air bubbles only when the eyes are below the water surface --- crates/horizon-client/src/game.rs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 7699e83d7..929a968c8 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -5495,17 +5495,9 @@ impl Game<'_> { } else { hud_layout::HeartKind::Normal }; - let eye = p.position.y + f64::from(p.dimensions.eye_height); - let under_water = self - .res - .facts() - .get(self.world.block( - p.position.x.floor() as i32, - eye.floor() as i32, - p.position.z.floor() as i32, - )) - .fluid - == horizon_client::blocks::Fluid::Water; + // Hud.extractAirBubbles: `isEyeInFluidMatching`, so the eyes are below + // the surface, not merely in the water block. + let under_water = p.is_eye_in_fluid(horizon_client::motion::WATER); let inputs = hud_layout::HealthInputs { tick: self.ticks as i32, millis: self.started.elapsed().as_millis() as i64, From eace14a013c83e9ff1d7f500367f0e49ca95a395 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 27 Oct 2026 11:58:19 +0100 Subject: [PATCH 25/27] rustfmt the step-sound match arms Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game.rs | 4 +--- crates/horizon-client/src/game/remote.rs | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index c45ea3a48..35cd657e7 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -4868,9 +4868,7 @@ impl Game<'_> { for event in events { match event { MotionEvent::HurtSound(sound) => self.player_hurt_sound(sound, feet), - MotionEvent::Emission { - state, muffled, .. - } => { + MotionEvent::Emission { state, muffled, .. } => { let sounds = self.res.facts().get(state).sounds.clone(); // Entity.playStepSound: the block's step sound at 0.15 volume, // muffled under the swim sound in water. Whether it plays is diff --git a/crates/horizon-client/src/game/remote.rs b/crates/horizon-client/src/game/remote.rs index 0611beb59..4244478ae 100644 --- a/crates/horizon-client/src/game/remote.rs +++ b/crates/horizon-client/src/game/remote.rs @@ -3417,9 +3417,7 @@ impl Game<'_> { let feet = [player.position.x, player.position.y, player.position.z]; for event in events { match event { - horizon_client::motion::MotionEvent::Emission { - state, muffled, .. - } => { + horizon_client::motion::MotionEvent::Emission { state, muffled, .. } => { let sounds = self.res.facts().get(state).sounds.clone(); // Player.playStepSound: muffled under the swim sound in water. let (volume, pitch) = if muffled { From fff7116b516a5a4f8ae1322a03f0d39a03cd1d2c Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 27 Oct 2026 12:12:33 +0100 Subject: [PATCH 26/27] Format the chat options or-pattern Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/options_ui.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/horizon-client/src/options_ui.rs b/crates/horizon-client/src/options_ui.rs index 2fe25c610..c4091af94 100644 --- a/crates/horizon-client/src/options_ui.rs +++ b/crates/horizon-client/src/options_ui.rs @@ -540,9 +540,9 @@ impl Opt { Opt::HideLightningFlashes => on_off(s.file.bool("hideLightningFlashes")), Opt::MonochromeLogo => on_off(s.file.bool("darkMojangStudiosBackground")), Opt::HideSplashTexts => on_off(s.file.bool("hideSplashTexts")), - Opt::HideMatchedNames - | Opt::OnlySecureChat - | Opt::SaveChatDrafts => on_off(s.file.bool(self.file_key().unwrap())), + Opt::HideMatchedNames | Opt::OnlySecureChat | Opt::SaveChatDrafts => { + on_off(s.file.bool(self.file_key().unwrap())) + } Opt::NarratorHotkey => on_off(s.file.bool("narratorHotkey")), Opt::RotateWithMinecarts => on_off(s.file.bool("rotateWithMinecart")), Opt::HighContrastBlockOutlines => on_off(s.file.bool("highContrastBlockOutline")), From 3094896ad1c0bd7ac221bb257af55e1127a1702a Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 27 Oct 2026 13:02:29 +0100 Subject: [PATCH 27/27] mob_ai probe: count hits that bring an effect as player hurts The new AttackPlayerWithEffect hit (husk, bee, cave spider...) still hurts the oracle's player, so the probe prints its hurt sound. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/examples/probe/mob_ai_probe.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/examples/probe/mob_ai_probe.rs b/crates/horizon-client/examples/probe/mob_ai_probe.rs index 5ea0a456b..ca9f566fa 100644 --- a/crates/horizon-client/examples/probe/mob_ai_probe.rs +++ b/crates/horizon-client/examples/probe/mob_ai_probe.rs @@ -567,7 +567,9 @@ fn print_heart( /// The damage of a mob's direct hit on the player (others count as none). fn player_damage(e: &MobEvent) -> f32 { match e { - MobEvent::AttackPlayer(amount, _) | MobEvent::DamagePlayer { amount, .. } => *amount, + MobEvent::AttackPlayer(amount, _) + | MobEvent::AttackPlayerWithEffect { amount, .. } + | MobEvent::DamagePlayer { amount, .. } => *amount, _ => 0.0, } } @@ -578,7 +580,9 @@ fn player_hurt(player: Option<&PlayerView>, e: &MobEvent) -> bool { return false; }; match e { - MobEvent::AttackPlayer(amount, _) | MobEvent::DamagePlayer { amount, .. } => *amount > 0.0, + MobEvent::AttackPlayer(amount, _) + | MobEvent::AttackPlayerWithEffect { amount, .. } + | MobEvent::DamagePlayer { amount, .. } => *amount > 0.0, // ServerExplosion.hurtEntities: within twice the radius every hit does damage. MobEvent::Explode(at, radius) => { let d = Vec3::new(at[0], at[1], at[2])