From 4b1e298a44ef7c180480d818af8ec4f5f29a5f65 Mon Sep 17 00:00:00 2001 From: Ganer Date: Fri, 23 Oct 2026 16:55:08 -0500 Subject: [PATCH 1/2] fix(worldgen): resolve upstream Rust 1.90 Clippy boolean warnings --- crates/horizon-world/src/block_survival.rs | 4 +- crates/horizon-world/src/edge_backoff.rs | 8 +-- crates/horizon-world/src/level/bonemeal.rs | 2 +- crates/horizon-world/src/level/speleothem.rs | 4 +- crates/horizon-world/src/level/tick.rs | 3 +- .../src/worldgen/aquifer/noise_based.rs | 31 ++++++++++- .../src/worldgen/feature_region.rs | 2 +- .../horizon-world/src/worldgen/placement.rs | 2 +- .../src/worldgen/structure/start.rs | 2 +- crates/horizon-world/tests/edge_backoff.rs | 53 +++++++++++++++++-- 10 files changed, 95 insertions(+), 16 deletions(-) diff --git a/crates/horizon-world/src/block_survival.rs b/crates/horizon-world/src/block_survival.rs index ae53451ba..f5c6d56a9 100644 --- a/crates/horizon-world/src/block_survival.rs +++ b/crates/horizon-world/src/block_survival.rs @@ -471,10 +471,10 @@ impl<'r> BlockSurvivalRegistry<'r> { .ignition_odds .get(&state.name) .is_some_and(|value| *value > 0) - && !state + && state .properties .get("waterlogged") - .is_some_and(|value| value == "true") + .is_none_or(|value| value != "true") }) .collect(), fence_gates: (0..registry.len()) diff --git a/crates/horizon-world/src/edge_backoff.rs b/crates/horizon-world/src/edge_backoff.rs index 7299d8c14..0dfebdae2 100644 --- a/crates/horizon-world/src/edge_backoff.rs +++ b/crates/horizon-world/src/edge_backoff.rs @@ -77,9 +77,11 @@ pub fn back_off_from_edge( ); world.no_collision(bounds).map_err(EdgeBackoffError::World) }; - if !grounded - && !(input.fall_distance < step && !can_fall(0.0, 0.0, step - input.fall_distance)?) - { + // Keep the collision query's short circuit: on-ground movement must not + // consume any budget, and an unordered (NaN) fall distance skips it too. + let should_back_off = grounded + || (input.fall_distance < step && !can_fall(0.0, 0.0, step - input.fall_distance)?); + if !should_back_off { return Ok(input.movement); } let mut x = input.movement.x; diff --git a/crates/horizon-world/src/level/bonemeal.rs b/crates/horizon-world/src/level/bonemeal.rs index 274512138..452aa7568 100644 --- a/crates/horizon-world/src/level/bonemeal.rs +++ b/crates/horizon-world/src/level/bonemeal.rs @@ -952,7 +952,7 @@ impl Sim<'_, L> { if crate::level::query::axis_of(spread) == crate::level::query::axis_of(from) { return None; } - if !(self.multiface_has_face(state, from) && !self.multiface_has_face(state, spread)) { + if !self.multiface_has_face(state, from) || self.multiface_has_face(state, spread) { return None; } let block = self.b.block(state); diff --git a/crates/horizon-world/src/level/speleothem.rs b/crates/horizon-world/src/level/speleothem.rs index 60059cfe9..7095db61f 100644 --- a/crates/horizon-world/src/level/speleothem.rs +++ b/crates/horizon-world/src/level/speleothem.rs @@ -276,8 +276,8 @@ impl Sim<'_, L> { if value > 0.175_781_25 { return; } - if !(self.speleothem_with(state, Direction::Down) - && !b.is_block(self.above_state(pos), b.block(state))) + if !self.speleothem_with(state, Direction::Down) + || b.is_block(self.above_state(pos), b.block(state)) { return; } diff --git a/crates/horizon-world/src/level/tick.rs b/crates/horizon-world/src/level/tick.rs index 0f640ef3a..bced59df9 100644 --- a/crates/horizon-world/src/level/tick.rs +++ b/crates/horizon-world/src/level/tick.rs @@ -565,7 +565,8 @@ impl Sim<'_, L> { return; } } - let burnout = self.level.dimension() == super::Dimension::Nether && false; + // Nether burnout is intentionally disabled: keep its behavior explicit. + let burnout = false; let extra = if burnout { -50 } else { 0 }; for (direction, chance) in [ (Direction::East, 300), diff --git a/crates/horizon-world/src/worldgen/aquifer/noise_based.rs b/crates/horizon-world/src/worldgen/aquifer/noise_based.rs index 3f3c7dc2c..60abbc371 100644 --- a/crates/horizon-world/src/worldgen/aquifer/noise_based.rs +++ b/crates/horizon-world/src/worldgen/aquifer/noise_based.rs @@ -447,7 +447,7 @@ impl NoiseBasedAquif let n = 3. + edge; if n > 0. { n / 3. } else { n / 10. } }; - let barrier = if q < -2. || q > 2. { + let barrier = if pressure_outside_interval(q) { 0. } else { if memo.is_nan() { @@ -603,6 +603,35 @@ impl NoiseBasedAquif Ok(Some(candidate)) } } +/// Preserve ordered floating-point comparisons, including NaN (which lies +/// neither below -2 nor above 2). Negating `RangeInclusive::contains` alone +/// would incorrectly treat NaN as outside the interval. +fn pressure_outside_interval(q: f64) -> bool { + !q.is_nan() && !(-2.0..=2.0).contains(&q) +} + fn similarity(a: i32, b: i32) -> f64 { 1. - b.wrapping_sub(a) as f64 / 25. } + +#[cfg(test)] +mod pressure_interval_tests { + use super::pressure_outside_interval; + + #[test] + fn outside_range_preserves_ordered_float_boundary_and_nan_behavior() { + for (q, expected) in [ + (f64::NAN, false), + (f64::NEG_INFINITY, true), + (-2.1, true), + (-2.0, false), + (-0.0, false), + (0.0, false), + (2.0, false), + (2.1, true), + (f64::INFINITY, true), + ] { + assert_eq!(pressure_outside_interval(q), expected, "q={q:?}"); + } + } +} diff --git a/crates/horizon-world/src/worldgen/feature_region.rs b/crates/horizon-world/src/worldgen/feature_region.rs index e1d80e8bc..5040846c6 100644 --- a/crates/horizon-world/src/worldgen/feature_region.rs +++ b/crates/horizon-world/src/worldgen/feature_region.rs @@ -519,7 +519,7 @@ impl<'r, B: TerrainBlockStates, F> TerrainFeatureAccess<'_, 'r, B, F> { }) } }; - Ok(!height.is_some_and(|height| !height.contains(position[1]))) + Ok(height.is_none_or(|height| height.contains(position[1]))) } } impl<'r, B: TerrainBlockStates, F> PlacementContext for TerrainFeatureAccess<'_, 'r, B, F> diff --git a/crates/horizon-world/src/worldgen/placement.rs b/crates/horizon-world/src/worldgen/placement.rs index 0c4ed8223..dd774f316 100644 --- a/crates/horizon-world/src/worldgen/placement.rs +++ b/crates/horizon-world/src/worldgen/placement.rs @@ -445,7 +445,7 @@ impl PlacementModifier { if !include_edges && (u8::from(bx) + u8::from(by) + u8::from(bz)) >= 2 { continue; } - if !include_interior && !(bx || by || bz) { + if !(*include_interior || bx || by || bz) { continue; } emit( diff --git a/crates/horizon-world/src/worldgen/structure/start.rs b/crates/horizon-world/src/worldgen/structure/start.rs index dcd4f1ed6..70e457b2e 100644 --- a/crates/horizon-world/src/worldgen/structure/start.rs +++ b/crates/horizon-world/src/worldgen/structure/start.rs @@ -196,7 +196,7 @@ impl RingSections { let squared = x.wrapping_mul(x).wrapping_add(z.wrapping_mul(z)); let distance = f64::from(squared).sqrt() as i32; let section = distance.wrapping_add(self.thickness - self.first) / self.thickness; - !self.max.is_some_and(|max| section > max) && section % 2 == 1 + self.max.is_none_or(|max| section <= max) && section % 2 == 1 } } diff --git a/crates/horizon-world/tests/edge_backoff.rs b/crates/horizon-world/tests/edge_backoff.rs index 501bc625d..e8f37057f 100644 --- a/crates/horizon-world/tests/edge_backoff.rs +++ b/crates/horizon-world/tests/edge_backoff.rs @@ -4,6 +4,7 @@ use horizon_world::edge_backoff::{ }; struct World { calls: usize, + grounded: bool, } impl EdgeBackoffWorld for World { type Error = std::convert::Infallible; @@ -14,7 +15,7 @@ impl EdgeBackoffWorld for World { Ok(true) } fn on_ground(&mut self) -> Result { - Ok(true) + Ok(self.grounded) } fn no_collision(&mut self, _: Aabb) -> Result { self.calls += 1; @@ -33,7 +34,10 @@ fn input() -> EdgeBackoffInput { } #[test] fn nonconverging_motion_exhausts_budget_without_successful_displacement() { - let mut world = World { calls: 0 }; + let mut world = World { + calls: 0, + grounded: true, + }; assert!(matches!( back_off_from_edge(&mut world, input()), Err(EdgeBackoffError::QueryBudget) @@ -42,7 +46,10 @@ fn nonconverging_motion_exhausts_budget_without_successful_displacement() { } #[test] fn zero_budget_only_fails_when_a_probe_is_needed() { - let mut world = World { calls: 0 }; + let mut world = World { + calls: 0, + grounded: true, + }; let mut request = input(); request.query_budget = 0; request.flying = true; @@ -60,3 +67,43 @@ fn zero_budget_only_fails_when_a_probe_is_needed() { )); assert_eq!(world.calls, 0); } + +#[test] +fn edge_check_preserves_grounded_and_unordered_fall_distance_short_circuit() { + // Neither already-grounded players nor NaN fall distances should query + // the world at all. The original `fall_distance < step` is false on NaN. + let mut world = World { + calls: 0, + grounded: true, + }; + let mut request = input(); + request.query_budget = 0; + request.movement = Vec3::new(0.0, 0.0, 0.0); + assert_eq!( + back_off_from_edge(&mut world, request).unwrap(), + Vec3::new(0.0, 0.0, 0.0) + ); + assert_eq!(world.calls, 0); + + world.grounded = false; + let mut request = input(); + request.query_budget = 0; + request.movement = Vec3::new(0.0, 0.0, 0.0); + request.fall_distance = f64::NAN; + assert_eq!( + back_off_from_edge(&mut world, request).unwrap(), + Vec3::new(0.0, 0.0, 0.0) + ); + assert_eq!(world.calls, 0); + + // An airborne player inside the step range must still attempt the + // collision query and report budget exhaustion rather than succeed. + let mut request = input(); + request.query_budget = 0; + request.fall_distance = 0.0; + assert!(matches!( + back_off_from_edge(&mut world, request), + Err(EdgeBackoffError::QueryBudget) + )); + assert_eq!(world.calls, 0); +} From e0d29dc23390fafbcf5a9befee9ac2fb1ac5d1e1 Mon Sep 17 00:00:00 2001 From: Ludovic Marie Date: Sat, 24 Oct 2026 11:31:38 +0200 Subject: [PATCH 2/2] Drop the aquifer helper and correct the fire burnout comment Stable Clippy (1.99, what CI runs) does not flag q < -2. || q > 2., so the helper and its test only served Rust 1.90's Clippy. Fire burnout is not 'intentionally disabled': vanilla's FireBlock.tick reads the INCREASED_FIRE_BURNOUT environment attribute, set by eight overworld biomes, which Horizon does not read yet; the comment now says so. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-world/src/edge_backoff.rs | 2 -- crates/horizon-world/src/level/tick.rs | 3 +- .../src/worldgen/aquifer/noise_based.rs | 31 +------------------ crates/horizon-world/tests/edge_backoff.rs | 4 +-- 4 files changed, 5 insertions(+), 35 deletions(-) diff --git a/crates/horizon-world/src/edge_backoff.rs b/crates/horizon-world/src/edge_backoff.rs index 0dfebdae2..4303b2d74 100644 --- a/crates/horizon-world/src/edge_backoff.rs +++ b/crates/horizon-world/src/edge_backoff.rs @@ -77,8 +77,6 @@ pub fn back_off_from_edge( ); world.no_collision(bounds).map_err(EdgeBackoffError::World) }; - // Keep the collision query's short circuit: on-ground movement must not - // consume any budget, and an unordered (NaN) fall distance skips it too. let should_back_off = grounded || (input.fall_distance < step && !can_fall(0.0, 0.0, step - input.fall_distance)?); if !should_back_off { diff --git a/crates/horizon-world/src/level/tick.rs b/crates/horizon-world/src/level/tick.rs index bced59df9..29f53e053 100644 --- a/crates/horizon-world/src/level/tick.rs +++ b/crates/horizon-world/src/level/tick.rs @@ -565,7 +565,8 @@ impl Sim<'_, L> { return; } } - // Nether burnout is intentionally disabled: keep its behavior explicit. + // FireBlock.tick reads the INCREASED_FIRE_BURNOUT environment attribute + // (jungles, swamps, peaks, mushroom fields); Horizon doesn't yet. let burnout = false; let extra = if burnout { -50 } else { 0 }; for (direction, chance) in [ diff --git a/crates/horizon-world/src/worldgen/aquifer/noise_based.rs b/crates/horizon-world/src/worldgen/aquifer/noise_based.rs index 60abbc371..3f3c7dc2c 100644 --- a/crates/horizon-world/src/worldgen/aquifer/noise_based.rs +++ b/crates/horizon-world/src/worldgen/aquifer/noise_based.rs @@ -447,7 +447,7 @@ impl NoiseBasedAquif let n = 3. + edge; if n > 0. { n / 3. } else { n / 10. } }; - let barrier = if pressure_outside_interval(q) { + let barrier = if q < -2. || q > 2. { 0. } else { if memo.is_nan() { @@ -603,35 +603,6 @@ impl NoiseBasedAquif Ok(Some(candidate)) } } -/// Preserve ordered floating-point comparisons, including NaN (which lies -/// neither below -2 nor above 2). Negating `RangeInclusive::contains` alone -/// would incorrectly treat NaN as outside the interval. -fn pressure_outside_interval(q: f64) -> bool { - !q.is_nan() && !(-2.0..=2.0).contains(&q) -} - fn similarity(a: i32, b: i32) -> f64 { 1. - b.wrapping_sub(a) as f64 / 25. } - -#[cfg(test)] -mod pressure_interval_tests { - use super::pressure_outside_interval; - - #[test] - fn outside_range_preserves_ordered_float_boundary_and_nan_behavior() { - for (q, expected) in [ - (f64::NAN, false), - (f64::NEG_INFINITY, true), - (-2.1, true), - (-2.0, false), - (-0.0, false), - (0.0, false), - (2.0, false), - (2.1, true), - (f64::INFINITY, true), - ] { - assert_eq!(pressure_outside_interval(q), expected, "q={q:?}"); - } - } -} diff --git a/crates/horizon-world/tests/edge_backoff.rs b/crates/horizon-world/tests/edge_backoff.rs index e8f37057f..4e6999205 100644 --- a/crates/horizon-world/tests/edge_backoff.rs +++ b/crates/horizon-world/tests/edge_backoff.rs @@ -70,8 +70,8 @@ fn zero_budget_only_fails_when_a_probe_is_needed() { #[test] fn edge_check_preserves_grounded_and_unordered_fall_distance_short_circuit() { - // Neither already-grounded players nor NaN fall distances should query - // the world at all. The original `fall_distance < step` is false on NaN. + // Neither grounded players nor NaN fall distances query the world: + // `fall_distance < step` is false for NaN. let mut world = World { calls: 0, grounded: true,