From e805e9886c06d37685c27e3056717e425da4aa59 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Mon, 19 Oct 2026 00:55:45 +0200 Subject: [PATCH] Scan for the motion-blocking top from the world surface, not the build limit getHeightmapPos(MOTION_BLOCKING) walked every column from y 319 down, one block lookup per y. Each precipitation roll (3 in 48 per ticking chunk per tick) and each isRainingAt paid for it: with the chunks of 10 players ticking it was most of tick_blocks. Only air lies above the WORLD_SURFACE heightmap the chunk already keeps, and air neither blocks motion nor holds a fluid, so the scan starts there. LevelAccess gains world_surface (the build limit by default, so other levels scan as before). Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game.rs | 3 +++ crates/horizon-world/src/level/mod.rs | 6 ++++++ crates/horizon-world/src/level/weather.rs | 6 ++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 2cbdabaa4..13d75817d 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -510,6 +510,9 @@ impl EntityObstructionWorld for PlayerObstruction { } } impl LevelAccess for GameLevel<'_> { + fn world_surface(&self, x: i32, z: i32) -> i32 { + self.world.world_surface(x, z, |s| self.facts.is_air(s)) + } fn precipitation(&self, pos: BlockPos) -> Option { self.behaviours.precipitation_info(self, pos) } diff --git a/crates/horizon-world/src/level/mod.rs b/crates/horizon-world/src/level/mod.rs index f1f0b21ac..c706ca280 100644 --- a/crates/horizon-world/src/level/mod.rs +++ b/crates/horizon-world/src/level/mod.rs @@ -301,6 +301,12 @@ pub trait LevelAccess { fn max_y(&self) -> i32 { 320 } + /// `getHeight(WORLD_SURFACE, x, z)`: one above the column's highest + /// block that isn't air. Only air lies above it, so scans for the other + /// heightmaps start there. The default, `max_y`, scans the whole column. + fn world_surface(&self, _x: i32, _z: i32) -> i32 { + self.max_y() + } /// Vanilla `level.random` (a `LegacyRandomSource`). fn random(&mut self) -> &mut LegacyRandom; fn game_time(&self) -> i64; diff --git a/crates/horizon-world/src/level/weather.rs b/crates/horizon-world/src/level/weather.rs index c43d96b15..93027d889 100644 --- a/crates/horizon-world/src/level/weather.rs +++ b/crates/horizon-world/src/level/weather.rs @@ -40,14 +40,16 @@ impl Behaviours { BiomePrecipitation::Rain } } - /// `getHeightmapPos(MOTION_BLOCKING, pos)`. + /// `getHeightmapPos(MOTION_BLOCKING, pos)`, scanning down from the + /// world surface (air neither blocks motion nor holds a fluid). pub fn motion_blocking_top( &self, level: &L, pos: BlockPos, ) -> BlockPos { let blocks = self.tag("minecraft:blocks_motion_in_heightmap"); - for y in (level.min_y()..level.max_y()).rev() { + let top = level.world_surface(pos.x, pos.z).min(level.max_y()); + for y in (level.min_y()..top).rev() { let state = level.block_state(BlockPos::new(pos.x, y, pos.z)); let fluid = self.fluid(state).kind() != FluidKind::Empty; if fluid || blocks.is_some_and(|t| t.contains(self.block(state))) {