diff --git a/crates/horizon-client/src/biome.rs b/crates/horizon-client/src/biome.rs index 46c1e16ca..291b719cc 100644 --- a/crates/horizon-client/src/biome.rs +++ b/crates/horizon-client/src/biome.rs @@ -66,6 +66,13 @@ impl BiomeInfo { } .height_adjusted(pos, sea_level) } + /// `Biome.getPrecipitationAt` in the Overworld (sea level 63): None + /// without precipitation, else whether it falls as snow + /// (`getHeightAdjustedTemperature` below 0.15). + pub fn snows_at(&self, x: i32, y: i32, z: i32) -> Option { + self.precipitation + .then(|| self.temperature_at(BlockPos::new(x, y, z), 63) < 0.15) + } } pub struct Biomes { pub list: Vec, diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 8590c6b58..5adb24550 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -10584,19 +10584,13 @@ impl Game<'_> { } } /// Whether precipitation at a column is snow (Biome.coldEnoughToSnow: - /// base temperature lowered above y 80) or none (no precipitation). + /// height adjusted temperature) or none (no precipitation). fn precipitation(&self, x: i32, y: i32, z: i32) -> Option { let chunk = self.world.chunks.get(&(x >> 4, z >> 4))?; - let b = self.res.biomes().get(chunk.biome(x, y, z)); - if !b.precipitation { - return None; - } - let t = if y > 80 { - b.temperature - (y - 80) as f32 * 0.05 / 40.0 - } else { - b.temperature - }; - Some(t < 0.15) + self.res + .biomes() + .get(chunk.biome(x, y, z)) + .snows_at(x, y, z) } /// `Level.isRainingAt`: it rains, the sky light is 15, nothing that stops /// motion is above, and the biome's precipitation there is rain. diff --git a/crates/horizon-client/src/game/render_tick.rs b/crates/horizon-client/src/game/render_tick.rs index a51f6c4e5..26a5a81cd 100644 --- a/crates/horizon-client/src/game/render_tick.rs +++ b/crates/horizon-client/src/game/render_tick.rs @@ -53,16 +53,7 @@ fn rains_at(world: &World, biomes: &Biomes, x: i32, y: i32, z: i32) -> bool { let Some(chunk) = world.chunks.get(&(x >> 4, z >> 4)) else { return false; }; - let b = biomes.get(chunk.biome(x, y, z)); - if !b.precipitation { - return false; - } - let t = if y > 80 { - b.temperature - (y - 80) as f32 * 0.05 / 40.0 - } else { - b.temperature - }; - t >= 0.15 + biomes.get(chunk.biome(x, y, z)).snows_at(x, y, z) == Some(false) } impl Game<'_> {