From dd86e16da28ed1b217ed55d0c1b66516b63a2b80 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Thu, 8 Oct 2026 15:40:01 +0200 Subject: [PATCH] Multiplayer: chat input by logical keys, net debug log, probe tick end The chat box reads logical keys so layouts and virtual keyboards type what they show; container screens hide the chat like vanilla's layering; HORIZON_NET_DEBUG=1 logs serverbound packets; horizon-ctl respawn; the probe ends a client tick after teleports (the server accepts one position per tick). Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game/remote.rs | 15 +++++++++------ crates/horizon-protocol/examples/probe.rs | 13 ++----------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/crates/horizon-client/src/game/remote.rs b/crates/horizon-client/src/game/remote.rs index ac9ecd11d..dec85e515 100644 --- a/crates/horizon-client/src/game/remote.rs +++ b/crates/horizon-client/src/game/remote.rs @@ -1462,21 +1462,22 @@ impl Game<'_> { } /// ChatScreen: typing, Enter to send, Escape to cancel. pub(super) fn remote_chat_key(&mut self, event: &winit::event::KeyEvent) { - use winit::keyboard::PhysicalKey; + use winit::keyboard::{Key, NamedKey}; if event.state != winit::event::ElementState::Pressed { return; } let Some(r) = self.remote.as_mut() else { return }; let Some(input) = r.chat_input.as_mut() else { return }; - match event.physical_key { - PhysicalKey::Code(KeyCode::Escape) => { + // Logical keys: the text, not the scancode, decides (layouts, virtual keyboards). + match &event.logical_key { + Key::Named(NamedKey::Escape) => { r.chat_input = None; self.capture(true); } - PhysicalKey::Code(KeyCode::Backspace) => { + Key::Named(NamedKey::Backspace) => { input.pop(); } - PhysicalKey::Code(KeyCode::Enter | KeyCode::NumpadEnter) => { + Key::Named(NamedKey::Enter) => { let message = r.chat_input.take().unwrap_or_default(); self.send_chat(&message); self.capture(true); @@ -1628,7 +1629,9 @@ impl Game<'_> { let open = r.chat_input.is_some(); let now = Instant::now(); let mut y = h - 48.0; - for (text, at) in r.chat.iter().rev().take(if open { 20 } else { 10 }) { + // Container screens cover the chat (vanilla draws them over the HUD). + let shown = if matches!(self.screen, Screen::Playing | Screen::Dead) { if open { 20 } else { 10 } } else { 0 }; + for (text, at) in r.chat.iter().rev().take(shown) { let age = now.duration_since(*at); // Lines fade out after ten seconds unless the chat is open. let alpha = if open { 1.0 } else { (1.0 - (age.as_secs_f32() - 9.0).max(0.0)).clamp(0.0, 1.0) }; diff --git a/crates/horizon-protocol/examples/probe.rs b/crates/horizon-protocol/examples/probe.rs index 241e3affe..005be919f 100644 --- a/crates/horizon-protocol/examples/probe.rs +++ b/crates/horizon-protocol/examples/probe.rs @@ -150,17 +150,8 @@ fn main() -> Result<(), Box> { }) .encode(), )?; - c.send( - &play::Serverbound::MovePlayerPosRot(play::MovePlayerPosRot { - x, - y, - z, - yaw: p.yaw, - pitch: p.pitch, - flags: 0, - }) - .encode(), - )?; + // One position per client tick: end the tick like the client. + c.send(&play::Serverbound::ClientTickEnd(Empty).encode())?; } play::Clientbound::ChunkBatchFinished(_) => { c.send(