[PR #90] [MERGED] F3 key combinations, as 26.3's KeyboardHandler runs them #2321

Closed
opened 2026-11-02 15:54:57 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/90
Author: @ludovic111
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @ludovic111

Base: main ← Head: fix/f3-combos-73


📝 Commits (1)

  • 70fad91 F3 key combinations, as 26.3's KeyboardHandler runs them

📊 Changes

18 files changed (+1694 additions, -36 deletions)

View changed files

📝 Cargo.lock (+131 -4)
📝 crates/horizon-client/Cargo.toml (+1 -0)
➕ crates/horizon-client/src/debug_keys.rs (+456 -0)
📝 crates/horizon-client/src/game.rs (+70 -3)
📝 crates/horizon-client/src/game/agent.rs (+1 -1)
📝 crates/horizon-client/src/game/commands.rs (+1 -1)
📝 crates/horizon-client/src/game/commands/extra.rs (+25 -22)
📝 crates/horizon-client/src/game/control.rs (+31 -1)
➕ crates/horizon-client/src/game/debug_keys.rs (+503 -0)
📝 crates/horizon-client/src/game/game_mode.rs (+4 -0)
📝 crates/horizon-client/src/game/hand.rs (+1 -1)
📝 crates/horizon-client/src/game/options.rs (+1 -1)
📝 crates/horizon-client/src/game/screens.rs (+4 -1)
📝 crates/horizon-client/src/game/stations.rs (+2 -1)
📝 crates/horizon-client/src/gfx.rs (+81 -0)
➕ crates/horizon-client/src/gizmos.rs (+347 -0)
📝 crates/horizon-client/src/lib.rs (+2 -0)
📝 crates/horizon-client/src/terrain.wgsl (+33 -0)

📄 Description

What was wrong

F3 only toggled the debug overlay. There were no F3 combinations (F3+C, F3+G, F3+B…), no F3+Escape, and no held-F3+C crash.

What vanilla 26.3 does

  • The debug keys are rebindable key mappings (Options.keyDebug*, category "debug"): modifier and overlay F3, crash C, reloadChunk A, showHitboxes B, clearChat D, showChunkBorders G, showAdvancedTooltips H, copyRecreateCommand I, spectate N, switchGameMode F4, debugOptions F6, focusPause P, dumpDynamicTextures S, reloadResourcePacks T, profiling L, copyLocation C, dumpVersion V, profilingChart/fpsCharts/networkCharts/lightmapTexture 1–4, improvedTransparency X. 26.3 has no F3+Q help list and no F3+F3 key: F3+Q is gone and F3+V/X/1–4 are new.
  • KeyboardHandler.keyPress: when modifier and overlay share a key, F3 released alone toggles the overlay unless it was used as a modifier (usedDebugKeyAsModifier). With the modifier down, handleDebugKeys runs every matching mapping in order, and a key that ran a debug action doesn't reach the game's mappings. Escape with the modifier calls pauseGame(true) (PauseScreen(false), only "Game Paused" at the top). Holding the modifier with the crash key arms debugCrashKeyTime; from 100 ms on, debug keys are swallowed.
  • KeyboardHandler.tick: after 1 s debug.crash.message, then debug.crash.warning each second with Mth.ceil(remaining / 1000F), then "Manually triggered debug crash" at 10 s.
  • Messages go through decorateDebugComponent: debug.prefix in bold yellow (red for warnings), a space, the message, via showDebugChat.
  • Gizmos: ChunkBorderRenderer.emitGizmos (outer columns 0x7FFF0000 at width 4, cell lines cyan/yellow at width 1, a ring every 2 blocks, major lines 0xFF3F3FFF, the camera's section always on top) and EntityHitboxDebugRenderer.showHitboxes (white box, red eye-height box, blue view arrow, dragon parts). GizmoFeatureRenderer.buildLines gives the width in pixels and clips at view z = −0.05.

The fix

  • debug_keys (library): keyPress/handleDebugKeys/tick as a state machine behind a DebugHost trait.
  • gizmos (library): lines, cuboids, arrows (Quaternionf.rotationTo tips), chunk-border and hitbox geometry, near-plane clipping. Plus a coloured line pipeline (vs_debug_line in terrain.wgsl, the rendertype_lines stroke with per-line colour and width), depth tested or always on top.
  • game/debug_keys: every action. A rebuilds all sections; B/G toggle the renderers (only with a player and without reduced debug info); C copies /execute in <dim> run tp @s x y z yRot xRot (%.2f, half up); D clears chat (sent history stays); H/P toggle advancedItemTooltips/pauseOnLostFocus in options.txt; I copies /setblock … state{nbt} or /summon id x y z {pretty nbt} with the server/client message (Shift); N switches spectator ↔ previous mode (MultiPlayerGameMode.previousLocalPlayerMode, creative by default) with /gamemode's feedback, or debug.creative_spectator.error; F4 without permission says debug.gamemodes.error; T reloads packs; V prints debug.version.header and /version's lines; X toggles improved transparency; held C crashes after saving (emergencySaveAndCrash).
  • pauseOnLostFocus now decides whether losing focus pauses; the menu-less pause draws only its title and ignores clicks.
  • Clipboard through arboard (Wayland data-control and X11); horizon-ctl status reports a debug object (overlay, hitboxes, chunk borders, pause menu, options, last copied text).

Tests

  • Unit tests replay vanilla key sequences on the state machine: F3 alone, a combination then F3, a rebound overlay key, F3+Escape, combinations behind a screen, refused actions (no player), the shared C key, and the crash countdown timings and messages. Gizmo tests cover the chunk-border line count, colours and positions, the hitbox shapes (f32 half width as in EntityDimensions.makeBoundingBox), and near-plane clipping.
  • In the game, through the control socket on the virtual screen: F3 toggles the overlay; F3+G/B draw the borders and hitboxes (screenshot checked); F3+C copies /execute in minecraft:overworld run tp @s 2.50 63.00 -3.50 0.00 0.00; F3+I on a chest copies /setblock … minecraft:chest[facing=east,type=single,waterlogged=false]{Items:[{Slot:0b,count:3,id:"minecraft:apple"}],components:{}} (server, or client with Shift); F3+N goes spectator and back; F3+Escape shows only "Game Paused"; F3+D/H/P/V/X work; holding F3+C warns, counts down, saves and exits.
  • Harnesses near the change still pass: options (17,524 cases), toggle keys (8,000), chat screen. cargo fmt --check, cargo clippy --workspace --all-targets -D warnings, cargo test --workspace and tools/check_public_tree.py pass.
  • No differential harness for the key handling itself. Driving the real KeyboardHandler.keyPress/handleDebugKeys needs a live Minecraft (window, GUI, level extractor, debug overlay), and a new harness would mean a new Python driver, which this task's rules exclude. The state machine is transcribed line by line from the bytecode, and its unit tests follow vanilla's branches.

Left open

  • F3+F4 game-mode switcher screen (GameModeSwitcherScreen: four item icons, default selection, mouse hover, /gamemode on release) is not drawn yet. With permission the key is consumed and nothing opens.
  • F3+F6 (debug options screen), F3+L (profiling), F3+S (dynamic texture dump) and F3+1/2/3/4 (profiler, FPS and network charts, lightmap) are consumed as in vanilla but have no effect yet.
  • Hitboxes cover mobs, the player in third person, dropped items and the dragon's parts. Boats, minecarts, armor stands, orbs, arrows and other entities are not included yet, nor is Gizmos.point (the 2 px position dot).
  • Advanced tooltips still add only the durability line. The item id and item.components lines are not shown yet.
  • F3+I copies mobs and blocks only (not boats, minecarts or other entity kinds). F3+N on a remote server does nothing (the client doesn't send ServerboundChangeGameModePacket yet).
  • Gizmo lines are drawn before translucent terrain, so water tints them.

Fixes #73

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/90 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/f3-combos-73` --- ### 📝 Commits (1) - [`70fad91`](https://github.com/horizon-rust/horizon/commit/70fad91ee5353b5828afc2dbe08d49d5984f8ea1) F3 key combinations, as 26.3's KeyboardHandler runs them ### 📊 Changes **18 files changed** (+1694 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+131 -4) 📝 `crates/horizon-client/Cargo.toml` (+1 -0) ➕ `crates/horizon-client/src/debug_keys.rs` (+456 -0) 📝 `crates/horizon-client/src/game.rs` (+70 -3) 📝 `crates/horizon-client/src/game/agent.rs` (+1 -1) 📝 `crates/horizon-client/src/game/commands.rs` (+1 -1) 📝 `crates/horizon-client/src/game/commands/extra.rs` (+25 -22) 📝 `crates/horizon-client/src/game/control.rs` (+31 -1) ➕ `crates/horizon-client/src/game/debug_keys.rs` (+503 -0) 📝 `crates/horizon-client/src/game/game_mode.rs` (+4 -0) 📝 `crates/horizon-client/src/game/hand.rs` (+1 -1) 📝 `crates/horizon-client/src/game/options.rs` (+1 -1) 📝 `crates/horizon-client/src/game/screens.rs` (+4 -1) 📝 `crates/horizon-client/src/game/stations.rs` (+2 -1) 📝 `crates/horizon-client/src/gfx.rs` (+81 -0) ➕ `crates/horizon-client/src/gizmos.rs` (+347 -0) 📝 `crates/horizon-client/src/lib.rs` (+2 -0) 📝 `crates/horizon-client/src/terrain.wgsl` (+33 -0) </details> ### 📄 Description ## What was wrong F3 only toggled the debug overlay. There were no F3 combinations (F3+C, F3+G, F3+B…), no F3+Escape, and no held-F3+C crash. ## What vanilla 26.3 does - The debug keys are rebindable key mappings (`Options.keyDebug*`, category "debug"): modifier and overlay F3, crash C, reloadChunk A, showHitboxes B, clearChat D, showChunkBorders G, showAdvancedTooltips H, copyRecreateCommand I, spectate N, switchGameMode F4, debugOptions F6, focusPause P, dumpDynamicTextures S, reloadResourcePacks T, profiling L, copyLocation C, dumpVersion V, profilingChart/fpsCharts/networkCharts/lightmapTexture 1–4, improvedTransparency X. **26.3 has no F3+Q help list and no F3+F3 key**: F3+Q is gone and F3+V/X/1–4 are new. - `KeyboardHandler.keyPress`: when modifier and overlay share a key, F3 released alone toggles the overlay unless it was used as a modifier (`usedDebugKeyAsModifier`). With the modifier down, `handleDebugKeys` runs every matching mapping in order, and a key that ran a debug action doesn't reach the game's mappings. Escape with the modifier calls `pauseGame(true)` (`PauseScreen(false)`, only "Game Paused" at the top). Holding the modifier with the crash key arms `debugCrashKeyTime`; from 100 ms on, debug keys are swallowed. - `KeyboardHandler.tick`: after 1 s `debug.crash.message`, then `debug.crash.warning` each second with `Mth.ceil(remaining / 1000F)`, then "Manually triggered debug crash" at 10 s. - Messages go through `decorateDebugComponent`: `debug.prefix` in bold yellow (red for warnings), a space, the message, via `showDebugChat`. - Gizmos: `ChunkBorderRenderer.emitGizmos` (outer columns 0x7FFF0000 at width 4, cell lines cyan/yellow at width 1, a ring every 2 blocks, major lines 0xFF3F3FFF, the camera's section always on top) and `EntityHitboxDebugRenderer.showHitboxes` (white box, red eye-height box, blue view arrow, dragon parts). `GizmoFeatureRenderer.buildLines` gives the width in pixels and clips at view z = −0.05. ## The fix - `debug_keys` (library): `keyPress`/`handleDebugKeys`/`tick` as a state machine behind a `DebugHost` trait. - `gizmos` (library): lines, cuboids, arrows (`Quaternionf.rotationTo` tips), chunk-border and hitbox geometry, near-plane clipping. Plus a coloured line pipeline (`vs_debug_line` in `terrain.wgsl`, the `rendertype_lines` stroke with per-line colour and width), depth tested or always on top. - `game/debug_keys`: every action. A rebuilds all sections; B/G toggle the renderers (only with a player and without reduced debug info); C copies `/execute in <dim> run tp @s x y z yRot xRot` (`%.2f`, half up); D clears chat (sent history stays); H/P toggle `advancedItemTooltips`/`pauseOnLostFocus` in options.txt; I copies `/setblock … state{nbt}` or `/summon id x y z {pretty nbt}` with the server/client message (Shift); N switches spectator ↔ previous mode (`MultiPlayerGameMode.previousLocalPlayerMode`, creative by default) with `/gamemode`'s feedback, or `debug.creative_spectator.error`; F4 without permission says `debug.gamemodes.error`; T reloads packs; V prints `debug.version.header` and `/version`'s lines; X toggles improved transparency; held C crashes after saving (`emergencySaveAndCrash`). - `pauseOnLostFocus` now decides whether losing focus pauses; the menu-less pause draws only its title and ignores clicks. - Clipboard through `arboard` (Wayland data-control and X11); `horizon-ctl status` reports a `debug` object (overlay, hitboxes, chunk borders, pause menu, options, last copied text). ## Tests - Unit tests replay vanilla key sequences on the state machine: F3 alone, a combination then F3, a rebound overlay key, F3+Escape, combinations behind a screen, refused actions (no player), the shared C key, and the crash countdown timings and messages. Gizmo tests cover the chunk-border line count, colours and positions, the hitbox shapes (f32 half width as in `EntityDimensions.makeBoundingBox`), and near-plane clipping. - In the game, through the control socket on the virtual screen: F3 toggles the overlay; F3+G/B draw the borders and hitboxes (screenshot checked); F3+C copies `/execute in minecraft:overworld run tp @s 2.50 63.00 -3.50 0.00 0.00`; F3+I on a chest copies `/setblock … minecraft:chest[facing=east,type=single,waterlogged=false]{Items:[{Slot:0b,count:3,id:"minecraft:apple"}],components:{}}` (server, or client with Shift); F3+N goes spectator and back; F3+Escape shows only "Game Paused"; F3+D/H/P/V/X work; holding F3+C warns, counts down, saves and exits. - Harnesses near the change still pass: options (17,524 cases), toggle keys (8,000), chat screen. `cargo fmt --check`, `cargo clippy --workspace --all-targets -D warnings`, `cargo test --workspace` and `tools/check_public_tree.py` pass. - **No differential harness for the key handling itself.** Driving the real `KeyboardHandler.keyPress`/`handleDebugKeys` needs a live `Minecraft` (window, GUI, level extractor, debug overlay), and a new harness would mean a new Python driver, which this task's rules exclude. The state machine is transcribed line by line from the bytecode, and its unit tests follow vanilla's branches. ## Left open - **F3+F4 game-mode switcher screen** (`GameModeSwitcherScreen`: four item icons, default selection, mouse hover, `/gamemode` on release) is not drawn yet. With permission the key is consumed and nothing opens. - **F3+F6** (debug options screen), **F3+L** (profiling), **F3+S** (dynamic texture dump) and **F3+1/2/3/4** (profiler, FPS and network charts, lightmap) are consumed as in vanilla but have no effect yet. - Hitboxes cover mobs, the player in third person, dropped items and the dragon's parts. Boats, minecarts, armor stands, orbs, arrows and other entities are not included yet, nor is `Gizmos.point` (the 2 px position dot). - Advanced tooltips still add only the durability line. The item id and `item.components` lines are not shown yet. - F3+I copies mobs and blocks only (not boats, minecarts or other entity kinds). F3+N on a remote server does nothing (the client doesn't send `ServerboundChangeGameModePacket` yet). - Gizmo lines are drawn before translucent terrain, so water tints them. Fixes #73 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:54:57 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2321
No description provided.