Natural spawning reads a kept WORLD_SURFACE heightmap
Every spawn attempt (`NaturalSpawner.getRandomPosWithin`) asks for the WORLD_SURFACE height of a column. Horizon scanned the column down for it each time, a chunk-map lookup and a block-name compare per block. Vanilla reads the chunk's heightmap. Chunks now keep WORLD_SURFACE: built on the first read, and dropped by a `set` that can move a column's surface (`Heightmap.update` leaves writes two or more below it alone). Natural spawning, the spawn rules' bat check and beacons read it. The unused `heights` field (never written after `Chunk::empty`) is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -589,11 +589,7 @@ impl SpawnLevel for super::MobWorld<'_> {
|
||||
self.sea_level
|
||||
}
|
||||
fn world_surface(&self, x: i32, z: i32) -> i32 {
|
||||
let top = crate::chunk::MIN_Y + crate::chunk::HEIGHT;
|
||||
(crate::chunk::MIN_Y..top)
|
||||
.rev()
|
||||
.find(|&y| !self.facts.is_air(self.world.block(x, y, z)))
|
||||
.map_or(crate::chunk::MIN_Y, |y| y + 1)
|
||||
self.world.world_surface(x, z, |id| self.facts.is_air(id))
|
||||
}
|
||||
fn peaceful(&self) -> bool {
|
||||
self.difficulty.effective == 0.0
|
||||
|
||||
Reference in New Issue
Block a user