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 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-08 15:40:01 +02:00
parent ed7e28101a
commit dd86e16da2
2 changed files with 11 additions and 17 deletions
+9 -6
View File
@@ -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) };
+2 -11
View File
@@ -150,17 +150,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
})
.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(