From 3319e6e204b985dceaed2d1b1d8094c861f6ea16 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Wed, 14 Oct 2026 23:34:45 +0200 Subject: [PATCH] The dragon fight's world fog, and void darkness from each dimension's floor EnderDragonFight's boss event sets createWorldFog, and while such a bar shows AtmosphericFogEnvironment.setupFog pulls the fog in (start at most 10, end at most 96, sky and cloud fog ending there): Horizon never did, so the End stayed clear during the fight. FogInputs gains boss_world_fog, set while the dragon's bar shows. FogRenderer's void darkness starts voidDarknessOnsetRange (32) above level.getMinY(), which is 0 in the Nether and the End; Horizon used the Overworld's -64 everywhere, so the End's fog never darkened below y 32. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/fog.rs | 57 +++++++++++++++++++ crates/horizon-client/src/game/dragon.rs | 7 ++- crates/horizon-client/src/game/render_tick.rs | 4 +- 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/fog.rs b/crates/horizon-client/src/fog.rs index 835a36a90..801b1e303 100644 --- a/crates/horizon-client/src/fog.rs +++ b/crates/horizon-client/src/fog.rs @@ -211,6 +211,9 @@ pub struct FogInputs<'a> { pub blindness: Option<(i32, bool)>, /// The darkness effect's blend factor, while the effect is on. pub darkness: Option, + /// `BossHealthOverlay.shouldCreateWorldFog`: a boss bar with + /// `createWorldFog` is shown (the Ender Dragon's). + pub boss_world_fog: bool, } /// `FogRenderer.setupFog` + `computeFogColor`. @@ -338,6 +341,12 @@ pub fn setup_fog(tables: &FogTables, state: &FogState, input: &FogInputs) -> Fog fog.environmental_end = min_end.max(sky.fog_end + -256.0 * state.rain_fog_multiplier); fog.sky_end = rd.min(512.0); fog.cloud_end = ((input.cloud_range_chunks * 16) as f32).min(sky.cloud_fog_end); + if input.boss_world_fog { + fog.environmental_start = fog.environmental_start.min(10.0); + fog.environmental_end = fog.environmental_end.min(96.0); + fog.sky_end = fog.environmental_end; + fog.cloud_end = fog.environmental_end; + } } } let span = (rd / 10.0).clamp(4.0, 64.0); @@ -385,9 +394,57 @@ mod tests { skybox: true, blindness: None, darkness: None, + boss_world_fog: false, } } #[test] + fn boss_world_fog_closes_in() { + // AtmosphericFogEnvironment.setupFog under a createWorldFog boss bar. + let sky = Sky { + fog_end: 1024.0, + cloud_fog_end: 2048.0, + ..Sky::default() + }; + let tables = FogTables { + water_fog_end: vec![1.0], + }; + let mut input = inputs(&sky); + input.boss_world_fog = true; + let fog = setup_fog(&tables, &FogState::default(), &input); + assert_eq!( + (fog.environmental_start, fog.environmental_end), + (0.0, 96.0) + ); + assert_eq!((fog.sky_end, fog.cloud_end), (96.0, 96.0)); + // Under water the water environment applies instead. + input.fog_type = FogType::Water; + let water = setup_fog(&tables, &FogState::default(), &input); + assert_eq!(water.environmental_start, -8.0); + } + #[test] + fn void_darkness_starts_32_above_the_floor() { + let sky = Sky { + fog_end: 1024.0, + fog_color: [0.5; 3], + sky_color: [0.5; 3], + ..Sky::default() + }; + let tables = FogTables { + water_fog_end: vec![1.0], + }; + let mut input = inputs(&sky); + // The End's floor is y 0: y 16 is halfway into the darkness. + input.min_y = 0; + input.camera_y = 16.0; + let fog = setup_fog(&tables, &FogState::default(), &input); + assert_eq!(fog.color[0], 0.5 * 0.25); + input.camera_y = 32.0; + assert_eq!( + setup_fog(&tables, &FogState::default(), &input).color[0], + 0.5 + ); + } + #[test] fn render_distance_fog_span() { let sky = Sky { fog_end: 1024.0, diff --git a/crates/horizon-client/src/game/dragon.rs b/crates/horizon-client/src/game/dragon.rs index a1cf7bfc2..a6a100187 100644 --- a/crates/horizon-client/src/game/dragon.rs +++ b/crates/horizon-client/src/game/dragon.rs @@ -1849,7 +1849,7 @@ impl Game<'_> { /// raids' and the custom bars, in that order. pub(super) fn draw_boss_bars(&self, batch: &mut HudBatch) { let mut bars = Vec::new(); - if let Some(d) = self.dragon.as_ref().filter(|_| self.dim == Dim::End) { + if let Some(d) = self.dragon.as_ref().filter(|_| self.dragon_bar_shown()) { bars.push(hud_overlays::BossBar { name: Text::literal( self.translate("entity.minecraft.ender_dragon", "Ender Dragon"), @@ -1870,6 +1870,11 @@ impl Game<'_> { ); hud_layout::paint(batch, &self.res.atlas, &draws); } + /// The dragon fight's boss bar shows (`EnderDragonFight.dragonEvent`, + /// with `setCreateWorldFog`). + pub(super) fn dragon_bar_shown(&self) -> bool { + self.dim == Dim::End && self.dragon.is_some() + } /// `music.dragon` while the boss bar plays music. pub(super) fn boss_music(&self) -> bool { self.dim == Dim::End && self.dragon.is_some() || self.wither_near() diff --git a/crates/horizon-client/src/game/render_tick.rs b/crates/horizon-client/src/game/render_tick.rs index 9fad97c5a..4c916e773 100644 --- a/crates/horizon-client/src/game/render_tick.rs +++ b/crates/horizon-client/src/game/render_tick.rs @@ -85,7 +85,8 @@ impl Game<'_> { render_distance_chunks: self.streaming.radius, cloud_range_chunks: self.settings.cloud_range, camera_y: camera.y, - min_y: MIN_Y, + // level.getMinY(): the Nether and the End start at y 0. + min_y: if self.dim == Dim::Overworld { MIN_Y } else { 0 }, flat: false, forward: forward.map(|c| c as f32), rain, @@ -93,6 +94,7 @@ impl Game<'_> { skybox: self.dim == Dim::Overworld, blindness: None, darkness: self.darkness_fog(), + boss_world_fog: self.dragon_bar_shown(), }) } /// `SkyRenderer.shouldRenderDarkDisc`: eye below the horizon (y 63) and not under water.