From 154aaa2051c76ca90e86cb8ffbab2a3670c6f138 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 22:32:05 +0100 Subject: [PATCH] Fix clippy and format the passive mob fixes --- crates/horizon-client/src/mobs/ai.rs | 9 +++++---- crates/horizon-client/src/mobs/equine.rs | 13 +++++++------ crates/horizon-client/src/mobs/finalize.rs | 5 ++++- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/crates/horizon-client/src/mobs/ai.rs b/crates/horizon-client/src/mobs/ai.rs index 6bd5a73df..5ed5fa0e1 100644 --- a/crates/horizon-client/src/mobs/ai.rs +++ b/crates/horizon-client/src/mobs/ai.rs @@ -1522,13 +1522,12 @@ pub fn age_up(m: &mut Mob, seconds: i32, forced: bool) { } } /// `Animal.playEatingSound` (empty) and its overrides, as (sound, volume, -/// pitch); `level` is the level's random. Pigs and cats use the classic sound -/// set, like their other sounds here. +/// pitch); `level` is the level's random. Pigs and cats play their sound +/// variant's set. pub fn eating_sound( m: &mut Mob, level: &mut impl RandomSource, ) -> Option<(&'static str, f32, f32)> { - let baby = m.is_baby(); // Mth.randomBetween(level.getRandom(), 0.8, 1.2). let mut between = || level.next_float() * 0.4 + 0.8; let (sound, volume, pitch, entity_sound) = match m.species() { @@ -1536,7 +1535,9 @@ pub fn eating_sound( Species::Armadillo | Species::Pig | Species::SulfurCube => { let sound = match m.species() { Species::Armadillo => "entity.armadillo.eat", - Species::Pig => super::finalize::variant_sound(m, "eat").unwrap_or("entity.pig.eat"), + Species::Pig => { + super::finalize::variant_sound(m, "eat").unwrap_or("entity.pig.eat") + } _ => "entity.small_sulfur_cube.eat", }; let pitch = m.voice_pitch(); diff --git a/crates/horizon-client/src/mobs/equine.rs b/crates/horizon-client/src/mobs/equine.rs index 200c537f2..b354a2908 100644 --- a/crates/horizon-client/src/mobs/equine.rs +++ b/crates/horizon-client/src/mobs/equine.rs @@ -127,9 +127,9 @@ pub fn finalize(m: &mut Mob) { } match species { Species::Horse => { - m.attrs.speed = (0.45 + r.next_double() * 0.3 + r.next_double() * 0.3 - + r.next_double() * 0.3) - * 0.25; + m.attrs.speed = + (0.45 + r.next_double() * 0.3 + r.next_double() * 0.3 + r.next_double() * 0.3) + * 0.25; m.extra.vector[0] = 0.4 + r.next_double() * 0.2 + r.next_double() * 0.2 + r.next_double() * 0.2; m.extra.variant = r.next_int_bound(7).unwrap_or(0) as u8; @@ -139,9 +139,10 @@ pub fn finalize(m: &mut Mob) { Species::ZombieHorse => { // ZombieHorse.generateZombieHorseJumpStrength and ...Speed. let d = 0.066_666_666_666_666_67; - m.extra.vector[0] = 0.5 + r.next_double() * d + r.next_double() * d + r.next_double() * d; - m.attrs.speed = (9.0 + r.next_double() + r.next_double() + r.next_double()) - / f64::from(42.16f32); + m.extra.vector[0] = + 0.5 + r.next_double() * d + r.next_double() * d + r.next_double() * d; + m.attrs.speed = + (9.0 + r.next_double() + r.next_double() + r.next_double()) / f64::from(42.16f32); } _ => { m.extra.vector[0] = diff --git a/crates/horizon-client/src/mobs/finalize.rs b/crates/horizon-client/src/mobs/finalize.rs index 8bc9a0b98..b360864ed 100644 --- a/crates/horizon-client/src/mobs/finalize.rs +++ b/crates/horizon-client/src/mobs/finalize.rs @@ -2081,7 +2081,10 @@ pub fn variant_sound(m: &Mob, kind: &str) -> Option<&'static str> { static IDS: Mutex>> = Mutex::new(None); let mut ids = IDS.lock().ok()?; let ids = ids.get_or_insert_with(HashMap::new); - Some(*ids.entry(id).or_insert_with_key(|k| Box::leak(k.clone().into_boxed_str()))) + Some( + *ids.entry(id) + .or_insert_with_key(|k| Box::leak(k.clone().into_boxed_str())), + ) } /// The registry name of the game's variant index. pub fn variant_name(s: Species, index: u8) -> &'static str {