Axolotl rain: the biome's height-adjusted temperature
Level.isRainingAt takes Biome.getHeightAdjustedTemperature, which applies the frozen oceans' temperature modifier and the height noise above the snow level; reuse horizon-world's version instead of a simplified copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//! Biome colours from the pinned biome definitions and colormaps
|
||||
//! (`Biome.getGrassColor`/`getFoliageColor`/..., `BlockTintSources`).
|
||||
use crate::Result;
|
||||
use horizon_core::{noise::SimplexNoise, random::LegacyRandom};
|
||||
use horizon_core::{noise::SimplexNoise, position::BlockPos, random::LegacyRandom};
|
||||
use serde_json::Value;
|
||||
use std::{collections::HashMap, fs, path::Path};
|
||||
|
||||
@@ -30,6 +30,8 @@ pub struct BiomeInfo {
|
||||
pub creature_probability: f32,
|
||||
pub name: String,
|
||||
pub temperature: f32,
|
||||
/// `temperature_modifier: frozen` (the frozen oceans).
|
||||
pub frozen: bool,
|
||||
pub downfall: f32,
|
||||
pub precipitation: bool,
|
||||
pub grass: u32,
|
||||
@@ -42,6 +44,26 @@ pub struct BiomeInfo {
|
||||
pub fog: Option<u32>,
|
||||
pub water_fog: u32,
|
||||
}
|
||||
impl BiomeInfo {
|
||||
/// `Biome.getHeightAdjustedTemperature`: the frozen modifier, then cooler
|
||||
/// with height above `sea_level + 17`.
|
||||
pub fn temperature_at(&self, pos: BlockPos, sea_level: i32) -> f32 {
|
||||
use horizon_world::worldgen::biome_temperature::{
|
||||
BiomeTemperatureSettings, TemperatureModifier,
|
||||
};
|
||||
BiomeTemperatureSettings {
|
||||
base_temperature: self.temperature,
|
||||
modifier: if self.frozen {
|
||||
TemperatureModifier::Frozen
|
||||
} else {
|
||||
TemperatureModifier::None
|
||||
},
|
||||
has_precipitation: self.precipitation,
|
||||
downfall: self.downfall,
|
||||
}
|
||||
.height_adjusted(pos, sea_level)
|
||||
}
|
||||
}
|
||||
pub struct Biomes {
|
||||
pub list: Vec<BiomeInfo>,
|
||||
pub index: HashMap<String, u16>,
|
||||
@@ -129,6 +151,7 @@ impl Biomes {
|
||||
.as_f64()
|
||||
.unwrap_or(0.1) as f32,
|
||||
temperature,
|
||||
frozen: v["temperature_modifier"].as_str() == Some("frozen"),
|
||||
downfall,
|
||||
precipitation: v["has_precipitation"].as_bool().unwrap_or(true),
|
||||
grass: color(&effects["grass_color"])
|
||||
|
||||
@@ -178,8 +178,8 @@ impl MobWorld<'_> {
|
||||
self.world.light(x, y, z) >> 4 == 15
|
||||
}
|
||||
/// Level.isRainingAt: raining, open to the sky, nothing motion blocking
|
||||
/// above, and the biome's precipitation at the position (its temperature
|
||||
/// lowered above the snow level) is rain, not snow or none.
|
||||
/// above, and the biome's precipitation at the position is rain, not snow
|
||||
/// or none.
|
||||
pub fn raining_at(&self, x: i32, y: i32, z: i32) -> bool {
|
||||
if !self.raining || !self.can_see_sky(x, y, z) || self.motion_blocking_height(x, z) > y {
|
||||
return false;
|
||||
@@ -188,13 +188,7 @@ impl MobWorld<'_> {
|
||||
return false;
|
||||
};
|
||||
let biome = self.biomes.get(chunk.biome(x, y, z));
|
||||
let snow_level = self.sea_level + 17;
|
||||
let temperature = if y > snow_level {
|
||||
biome.temperature - (y - snow_level) as f32 * 0.05 / 40.0
|
||||
} else {
|
||||
biome.temperature
|
||||
};
|
||||
biome.precipitation && temperature >= 0.15
|
||||
biome.precipitation && biome.temperature_at(BlockPos::new(x, y, z), self.sea_level) >= 0.15
|
||||
}
|
||||
/// Level.getLightLevelDependentMagicValue: the dimension's brightness curve
|
||||
/// at the raw (sky darkened) light level.
|
||||
|
||||
Reference in New Issue
Block a user