Merge pull request #198 from ludovic111/fix/end-fog-103

The dragon fight's world fog and the End's void darkness floor
This commit is contained in:
Ludovic Marie
2026-10-15 00:02:15 +02:00
committed by GitHub
3 changed files with 66 additions and 2 deletions
+57
View File
@@ -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<f32>,
/// `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,
+6 -1
View File
@@ -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()
@@ -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.