Use the flat world's horizon height for the dark disc and void fog

This commit is contained in:
Kacpherek
2026-10-26 15:16:33 +01:00
parent 8027cb4176
commit 94592a35ac
5 changed files with 33 additions and 5 deletions
+5
View File
@@ -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(),
+2 -1
View File
@@ -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());
+4
View File
@@ -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<String>,
player_type: Option<Arc<MobType>>,
/// 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();
+17 -3
View File
@@ -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(),
+5 -1
View File
@@ -147,6 +147,9 @@ pub struct Hub {
/// An integrated server's owner (`MinecraftServer.isSingleplayerOwner`),
/// whose moves are never checked.
pub singleplayer_owner: Option<u128>,
/// 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,