From 94592a35ac5922d6f79b5ad53e1a3f71034d4c2e Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 15:16:33 +0100 Subject: [PATCH] Use the flat world's horizon height for the dark disc and void fog --- crates/horizon-client/src/game.rs | 5 +++++ crates/horizon-client/src/game/lan.rs | 3 ++- crates/horizon-client/src/game/remote.rs | 4 ++++ crates/horizon-client/src/game/render_tick.rs | 20 ++++++++++++++++--- crates/horizon-client/src/lan/hub.rs | 6 +++++- 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 1d86fe990..23b66e649 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -1389,6 +1389,8 @@ struct Game<'a> { sleep_timer: u32, dim: Dim, world_root: PathBuf, + /// The world's overworld is superflat (`ClientLevelData.isFlat`). + overworld_flat: bool, /// A player carried through a portal, re-placed once the destination loads. travelling: Option<(PlayerMotion, Vec3)>, /// A server's players on their way to another level, each waiting for @@ -7936,6 +7938,8 @@ impl Game<'_> { book.to_be_displayed.retain(|r| index.contains(r)); self.dim = dim; self.world_root = save_root.clone(); + self.overworld_flat = + horizon_client::save::WorldGen::read(&save_root).is_some_and(|w| w.flat); self.block_ticks = Ticks::new(self.level.seed as i32); self.tick_chunks.clear(); self.clear_entities(); @@ -12272,6 +12276,7 @@ impl<'a> Game<'a> { sleep_timer: 0, dim: Dim::Overworld, world_root: PathBuf::new(), + overworld_flat: false, travelling: None, server_trips: Vec::new(), level_teleports: Vec::new(), diff --git a/crates/horizon-client/src/game/lan.rs b/crates/horizon-client/src/game/lan.rs index 61003e085..30ba4bcb0 100644 --- a/crates/horizon-client/src/game/lan.rs +++ b/crates/horizon-client/src/game/lan.rs @@ -582,7 +582,8 @@ impl Game<'_> { let host_uuid = host.unwrap_or(0); self.next_entity += 1; let host_entity = self.next_entity as i32; - let hub = Hub::new(lan, sync, encoder, config); + let mut hub = Hub::new(lan, sync, encoder, config); + hub.flat_overworld = self.overworld_flat; let port = hub.lan.port; self.world.block_log = Some(Vec::new()); self.world.light_log = Some(Default::default()); diff --git a/crates/horizon-client/src/game/remote.rs b/crates/horizon-client/src/game/remote.rs index 857f955da..b83bd6d66 100644 --- a/crates/horizon-client/src/game/remote.rs +++ b/crates/horizon-client/src/game/remote.rs @@ -189,6 +189,8 @@ pub(super) struct Remote { input: horizon_client::interaction_input::InteractionInput, stop_mining: bool, placing: Option<([i32; 3], u64)>, + /// `CommonPlayerSpawnInfo.isFlat`: the level is a superflat one. + pub(super) flat: bool, death_message: Option, player_type: Option>, /// Inventory as last synchronised, for creative-mode slot updates. @@ -472,6 +474,7 @@ impl Game<'_> { input: Default::default(), stop_mining: false, placing: None, + flat: false, death_message: None, player_type, synced: vec![None; 36], @@ -981,6 +984,7 @@ impl Game<'_> { r.chunk_format = Arc::new(r.chunk_format.with_dimension(&dimension)); r.dimension = dimension; r.game_mode = spawn.game_type; + r.flat = spawn.flat; r.loaded_sent = false; // A replacement LocalPlayer has a fresh sendPosition baseline. r.position_sender = Default::default(); diff --git a/crates/horizon-client/src/game/render_tick.rs b/crates/horizon-client/src/game/render_tick.rs index e013c8d29..36840dabd 100644 --- a/crates/horizon-client/src/game/render_tick.rs +++ b/crates/horizon-client/src/game/render_tick.rs @@ -93,7 +93,7 @@ impl Game<'_> { camera_y: camera.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, + flat: self.level_flat(), forward: forward.map(|c| c as f32), rain, thunder, @@ -107,9 +107,23 @@ impl Game<'_> { }, ) } - /// `SkyRenderer.shouldRenderDarkDisc`: eye below the horizon (y 63) and not under water. + /// `ClientLevelData.isFlat`: on the server thread, as its spawn info said. + fn level_flat(&self) -> bool { + match self.remote.as_ref() { + Some(r) => r.flat, + None => self.dim == Dim::Overworld && self.overworld_flat, + } + } + /// `SkyRenderer.shouldRenderDarkDisc`: eye below the horizon and not under + /// water. `ClientLevelData.getHorizonHeight`: the bottom of a flat world, + /// otherwise y 63. pub(super) fn dark_disc(&self, camera: glam::DVec3) -> bool { - camera.y < 63.0 + let horizon = if self.level_flat() { + f64::from(MIN_Y) + } else { + 63.0 + }; + camera.y < horizon && fog_type( &self.world, self.res.facts(), diff --git a/crates/horizon-client/src/lan/hub.rs b/crates/horizon-client/src/lan/hub.rs index 910911d80..96e043492 100644 --- a/crates/horizon-client/src/lan/hub.rs +++ b/crates/horizon-client/src/lan/hub.rs @@ -147,6 +147,9 @@ pub struct Hub { /// An integrated server's owner (`MinecraftServer.isSingleplayerOwner`), /// whose moves are never checked. pub singleplayer_owner: Option, + /// The overworld is superflat (`ServerLevel.isFlat`, sent as + /// `CommonPlayerSpawnInfo.isFlat`). + pub flat_overworld: bool, /// Who rides what, set by the game before each tick. pub riding: super::entity::Riding, /// The scoreboard's teams, set by the game each tick, for players' @@ -321,6 +324,7 @@ impl Hub { ticks: 0, movement_checks: (true, true), singleplayer_owner: None, + flat_overworld: false, riding: Default::default(), last_clock: i64::MIN, last_rate: 0.0, @@ -548,7 +552,7 @@ impl Hub { game_type: game_mode, previous_game_type: None, debug: false, - flat: false, + flat: self.flat_overworld && self.config.dimension == "minecraft:overworld", last_death: None, portal_cooldown: 0, sea_level: 63,