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..4303b2d74 100644 --- a/crates/horizon-world/src/edge_backoff.rs +++ b/crates/horizon-world/src/edge_backoff.rs @@ -77,9 +77,9 @@ 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)?) - { + 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..29f53e053 100644 --- a/crates/horizon-world/src/level/tick.rs +++ b/crates/horizon-world/src/level/tick.rs @@ -565,7 +565,9 @@ impl Sim<'_, L> { return; } } - let burnout = self.level.dimension() == super::Dimension::Nether && false; + // 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 [ (Direction::East, 300), 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..4e6999205 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 grounded players nor NaN fall distances query the world: + // `fall_distance < step` is false for 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); +}