Merge pull request #1552 from ludovic111/cg3/pr1502-fixup

This commit is contained in:
Ludovic Marie
2026-10-24 14:30:12 +02:00
committed by GitHub
9 changed files with 64 additions and 15 deletions
+2 -2
View File
@@ -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())
+3 -3
View File
@@ -77,9 +77,9 @@ pub fn back_off_from_edge<W: EdgeBackoffWorld>(
);
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;
+1 -1
View File
@@ -952,7 +952,7 @@ impl<L: LevelAccess + ?Sized> 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);
+2 -2
View File
@@ -276,8 +276,8 @@ impl<L: LevelAccess + ?Sized> 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;
}
+3 -1
View File
@@ -565,7 +565,9 @@ impl<L: LevelAccess + ?Sized> 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),
@@ -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>
@@ -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(
@@ -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
}
}
+50 -3
View File
@@ -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<bool, Self::Error> {
Ok(true)
Ok(self.grounded)
}
fn no_collision(&mut self, _: Aabb) -> Result<bool, Self::Error> {
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);
}