From df23e1bfed0c2fde5d9c319ccae18fed3c6b036b Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sun, 25 Oct 2026 17:27:41 +0100 Subject: [PATCH] Keep vanilla's death screen message; resolve with the loaded language - Leave ServerPlayer.die's message as it was: with showDeathMessages off vanilla sends CommonComponents.EMPTY to the death screen, and #1858 reworks the death message from the combat record. - The effects panel and recipe book tooltips use Names::display_get, so a key missing from the language still falls back instead of showing the key. - net::load_language reuses the language lang already loaded (packs included) instead of reading it from disk again. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game/lan_actions.rs | 48 +++++++++---------- crates/horizon-client/src/game/potions.rs | 2 +- crates/horizon-client/src/game/recipe_book.rs | 2 +- crates/horizon-client/src/net.rs | 18 ++++--- 4 files changed, 37 insertions(+), 33 deletions(-) diff --git a/crates/horizon-client/src/game/lan_actions.rs b/crates/horizon-client/src/game/lan_actions.rs index 03bb15b65..2c7019c73 100644 --- a/crates/horizon-client/src/game/lan_actions.rs +++ b/crates/horizon-client/src/game/lan_actions.rs @@ -1791,33 +1791,33 @@ impl Game<'_> { // ServerPlayer.die: dropAllDeathLoot unless a spectator, from the eyes less 0.3. let drops = (g.game_mode != SPECTATOR) .then(|| [at[0], at[1] + g.eye_height() - 0.3, at[2]]); - // ServerPlayer.die: the death screen always shows the message; - // chat only when the rule allows and the team does not hide it. let cause = host.play.get_mut(&conn).and_then(|p| p.death_cause.take()); - let key = cause.unwrap_or_else(|| { - if at[1] < f64::from(horizon_client::chunk::MIN_Y - 64) { - "death.attack.outOfWorld".into() - } else { - "death.attack.generic".into() - } - }); - let text = - horizon_client::text::Text::translate(&key, &[self.player_text(&name, uuid)]); - let message = horizon_client::lan::data::component_nbt(&text.component()); - if self.ui.rules.bool("show_death_messages") { - let team = self.score.board.players_team(&name); - if horizon_client::scoreboard::own_death_message_shown(team) { - host.hub.system_message(message.clone()); - if self.options.dedicated.is_some() { - super::dedicated::log( - "INFO", - &format!("System chat: {}", text.plain()), - ); - } else if self.player.is_some() { - self.system_message(text); + let message = match cause { + // ServerPlayer.die: the death message, to everyone unless + // the player's team hides it. + Some(key) if self.ui.rules.bool("show_death_messages") => { + let text = horizon_client::text::Text::translate( + &key, + &[self.player_text(&name, uuid)], + ); + let message = horizon_client::lan::data::component_nbt(&text.component()); + let team = self.score.board.players_team(&name); + if horizon_client::scoreboard::own_death_message_shown(team) { + host.hub.system_message(message.clone()); + if self.options.dedicated.is_some() { + super::dedicated::log( + "INFO", + &format!("System chat: {}", text.plain()), + ); + } else if self.player.is_some() { + self.system_message(text); + } } + message } - } + Some(_) => literal(""), + None => literal(&format!("{name} died")), + }; host.hub.send_to( conn, &C::PlayerCombatKill(play::PlayerCombatKill { id, message }), diff --git a/crates/horizon-client/src/game/potions.rs b/crates/horizon-client/src/game/potions.rs index 49e171ce1..b28c2fb4d 100644 --- a/crates/horizon-client/src/game/potions.rs +++ b/crates/horizon-client/src/game/potions.rs @@ -755,7 +755,7 @@ impl Game<'_> { image_width, &self.potions.effects.list, self.clock.rate(), - &|key| Some(horizon_client::lang::get(key)), + &|key| self.pack.names.display_get(key), &|text| self.gui.atlas.font.width(text).ceil() as i32, ); if let Some(lines) = inventory_effects::paint( diff --git a/crates/horizon-client/src/game/recipe_book.rs b/crates/horizon-client/src/game/recipe_book.rs index f68460b7d..fd44041e5 100644 --- a/crates/horizon-client/src/game/recipe_book.rs +++ b/crates/horizon-client/src/game/recipe_book.rs @@ -502,7 +502,7 @@ impl Game<'_> { horizon_client::item_tooltip::lines( stack, self.res.items().get(&stack.item), - &|k| Some(horizon_client::lang::get(k)), + &|k| self.pack.names.display_get(k), ) }) { diff --git a/crates/horizon-client/src/net.rs b/crates/horizon-client/src/net.rs index 2b314f2a8..8acfa7ec9 100644 --- a/crates/horizon-client/src/net.rs +++ b/crates/horizon-client/src/net.rs @@ -597,14 +597,18 @@ pub fn json_text(v: &serde_json::Value, lang: &Language) -> String { } } -/// The language a session resolves server-sent components with: the client's -/// selected language, layered over `en_us` (`ClientLanguage.loadFrom`), so a -/// menu title the server sends as a key follows the language screen. +/// The language a session resolves server-sent components with: the selected +/// one as `lang` loaded it (`en_us` under it, packs included), so a menu title +/// the server sends as a key follows the language screen. A process with no +/// language set (a dedicated server's log) reads en_us.json. pub fn load_language(resources: &std::path::Path) -> Language { - let root = resources.to_path_buf(); - crate::lang::Language::load(&[&root], &crate::lang::code()) - .map() - .clone() + if let Some(lang) = crate::lang::current() { + return lang.map().clone(); + } + std::fs::read(resources.join("assets/minecraft/lang/en_us.json")) + .ok() + .and_then(|b| serde_json::from_slice(&b).ok()) + .unwrap_or_default() } /// Ask a server for its status (ServerStatusPinger): MOTD, players and the