Merge pull request #2182 from kacpherek/fix/weather-command-without-cycle

🤖 Agent: Gate check by Ludovic's AI agent (Claude). Checked against 26.3: `/weather` sets the weather whether or not `advance_weather` is on. Gate: this wave's 55 PRs merged on main in one tree: clippy `-D warnings` clean, 1186 horizon-client and 163 horizon-world tests pass, and of the 101 harnesses `parity.py --changed-files` picked, 100 pass (`block_removal` failed on one spawner case from #2199's orb merging, fixed there). `lan_e2e.py` passes 24 checks with the host on its server thread and in-frame (chest, xp, pvp, doors, villagers, beds, frames, projectiles, arrows, fishing, damage, mobs, blast, drops, elytra, breath, predict, cracks, barter, kills, hurt, contacts, underwater, plates), plus forced-levels on the server thread. Thanks @kacpherek!
This commit is contained in:
Ludovic Marie
2026-10-26 19:00:56 +01:00
committed by GitHub
2 changed files with 9 additions and 2 deletions
+2 -1
View File
@@ -4334,8 +4334,9 @@ impl Game<'_> {
if running {
self.world.game_time += 1;
if self.ui.rules.bool("advance_weather") {
self.world.weather.tick(&mut self.world.random);
self.world.weather.tick_timers(&mut self.world.random);
}
self.world.weather.tick_levels();
self.tick_weather_effects();
}
if self.ticks.is_multiple_of(6000) {
+7 -1
View File
@@ -109,7 +109,9 @@ pub struct Weather {
pub thunder_level: (f32, f32),
}
impl Weather {
pub fn tick(&mut self, random: &mut horizon_core::random::LegacyRandom) {
/// The timers of `advanceWeatherCycle`, which run only while
/// `advance_weather` is on.
pub fn tick_timers(&mut self, random: &mut horizon_core::random::LegacyRandom) {
use horizon_core::random::RandomSource;
let mut uniform =
|min: i32, max: i32| min + random.next_int_bound(max - min + 1).unwrap_or(0);
@@ -141,6 +143,10 @@ impl Weather {
self.rain_time = uniform(12000, 180000);
}
}
}
/// The rain and thunder level fade at the end of `advanceWeatherCycle`,
/// which runs whatever `advance_weather` says, so `/weather` still shows.
pub fn tick_levels(&mut self) {
self.thunder_level.0 = self.thunder_level.1;
self.thunder_level.1 =
(self.thunder_level.1 + if self.thundering { 0.01 } else { -0.01 }).clamp(0.0, 1.0);