[PR #4004] [MERGED] Both mouse buttons at once replace the block in creative #5348

Closed
opened 2026-11-03 05:11:58 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4004
Author: @d3grando
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @levzzz5154

Base: main ← Head: fix-3006


📝 Commits (1)

  • 0ce65d3 Both mouse buttons at once replace the block in creative

📊 Changes

5 files changed (+109 additions, -9 deletions)

View changed files

📝 crates/horizon-client-input/src/interaction_input.rs (+73 -0)
📝 crates/horizon-client/examples/probe/interaction_input_fixture.rs (+3 -0)
📝 crates/horizon-client/src/game.rs (+11 -6)
📝 crates/horizon-client/src/game/lan_actions.rs (+16 -3)
📝 crates/horizon-client/src/game/remote.rs (+6 -0)

📄 Description

🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando personally.

What and why

In creative, pressing left and right click together on a block should swap it for the held block. In Horizon the block just broke. Sometimes the new block showed up for a moment and then went away.

There were two causes, one on each side:

  • Client: the hit result was re-picked for every click. Minecraft.tick calls pick(1.0F) once, before handleKeybinds. startAttack, startUseItem, continueAttack and pickBlockOrEntity then all read that same this.hitResult. Horizon's Game::pick cast a new ray on every call. So after the creative START predicted the break, the use in the same tick aimed past the broken block: at nothing, or at the block behind it. InteractionInput::tick now calls two new InteractionWorld hooks around the tick's clicks, pick_hit_result and release_hit_result. On a server's client they fill and clear a tick_hit that Game::pick returns while it is set. Outside the click handling, picks follow the crosshair as before.
  • Server: a creative START was deferred to the guest tick. The host recorded the START as a dig and broke the block in tick_guests. That runs after every packet of the batch, including the UseItemOn sent right behind the START. So the use placed against the old block (next to it), and then the old block broke. That is the "appears for a second" case. ServerPlayerGameMode.handleBlockBreakAction destroys at once for an instabuild player (destroyAndAck(pos, sequence, "creative destroy")). The host now does the same at packet time and clears the dig. Survival STARTs are unchanged.

I checked both halves in game. With only the client fix, the diamond block ended up next to the broken stone instead of in its place. With both fixes, it replaces the stone.

The in-frame host path (HORIZON_SERVER_THREAD=0, deprecated) handles clicks differently and is not changed here.

Fixes #3006

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

  • net.minecraft.client.Minecraft.tick: pick(1.0F) (sets hitResult), then handleKeybinds. startAttack, startUseItem, continueAttack and pickBlockOrEntity all read this.hitResult (javap of the 26.3 client.jar).
  • net.minecraft.server.level.ServerPlayerGameMode.handleBlockBreakAction: for getAbilities().instabuild it calls destroyAndAck(pos, sequence, "creative destroy") while handling the packet.
  • BlockItem.place / BlockPlaceContext: the clicked block, now air, can be replaced, so the placement goes there.
  • Test: interaction_input::tests::attack_and_use_in_one_tick_share_the_hit_result. Harness: tools/test_interaction_input_parity.py still matches the real handleKeybinds (its fixture gets no-op hooks).

Self-check

tools/pr_ready.py doesn't run on Windows (it needs SIGHUP), so I ran its steps by hand, on the branch rebased onto current main:

  • cargo fmt --all -- --check: clean
  • cargo clippy -p horizon-client-input --all-targets -- -D warnings: clean
  • cargo clippy -p horizon-client --all-targets -- -D warnings: clean
  • cargo test -p horizon-client-input --lib: 49 passed
  • cargo test -p horizon-client --bin horizon-client -- remote:: lan_actions::: 7 passed
  • python tools/test_interaction_input_parity.py: 392 cases match the pinned client (1,484 output lines)
  • New test, run with the two hook calls in InteractionInput::tick removed (code only, test kept): attack_and_use_in_one_tick_share_the_hit_result ... FAILED ("the use acts on the block the attack broke"). With the calls back: 5 passed.
  • In game, single player on the server thread, creative, floating stone, diamond block in hand, mouse left click + mouse right click sent back to back:
    • Before: the stone broke and nothing was placed (3/3).
    • Client fix only: the diamond block landed next to the stone's spot.
    • Both fixes: the diamond block replaced the stone (5/5; execute if block ... diamond_block passes on the server).
  • LAN guest on a second game: the same replace works, and the server agrees.
    • Some tries placed nothing. In those tries the two ctl commands landed in different client ticks, as with real clicks, and nothing was ever placed next to the stone. The host showed the same split once both windows were throttled to 30 fps.
  • Regression checks, host and guest:
    • A creative left click alone breaks the block, and a block set back afterwards stays.
    • Holding left in creative breaks blocks one after another.
    • A right click alone still places next to the block.
    • A survival guest's instant break (dead bush) still works, and a bush set back stays.
  • tools/lan_e2e.py --check vehicles --check instant_digging doesn't start on this Windows machine (os.symlink needs a privilege it lacks), so I ran its creative break-and-put-back steps by hand as above.

Screenshots

before: both buttons at once leave empty air where the stone was

after: the diamond block replaces the stone

Before: in creative with a diamond block in hand, aiming at a floating stone and pressing both buttons leaves empty air where the stone was.
After: the same press puts the diamond block exactly where the stone was.

🤖 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/4004 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3006` --- ### 📝 Commits (1) - [`0ce65d3`](https://github.com/horizon-rust/horizon/commit/0ce65d34c68fe081c8fbf7d7a3af108652a62d92) Both mouse buttons at once replace the block in creative ### 📊 Changes **5 files changed** (+109 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-input/src/interaction_input.rs` (+73 -0) 📝 `crates/horizon-client/examples/probe/interaction_input_fixture.rs` (+3 -0) 📝 `crates/horizon-client/src/game.rs` (+11 -6) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+16 -3) 📝 `crates/horizon-client/src/game/remote.rs` (+6 -0) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando personally. ## What and why In creative, pressing left and right click together on a block should swap it for the held block. In Horizon the block just broke. Sometimes the new block showed up for a moment and then went away. There were two causes, one on each side: - **Client: the hit result was re-picked for every click.** `Minecraft.tick` calls `pick(1.0F)` once, before `handleKeybinds`. `startAttack`, `startUseItem`, `continueAttack` and `pickBlockOrEntity` then all read that same `this.hitResult`. Horizon's `Game::pick` cast a new ray on every call. So after the creative START predicted the break, the use in the same tick aimed past the broken block: at nothing, or at the block behind it. `InteractionInput::tick` now calls two new `InteractionWorld` hooks around the tick's clicks, `pick_hit_result` and `release_hit_result`. On a server's client they fill and clear a `tick_hit` that `Game::pick` returns while it is set. Outside the click handling, picks follow the crosshair as before. - **Server: a creative START was deferred to the guest tick.** The host recorded the START as a dig and broke the block in `tick_guests`. That runs after every packet of the batch, including the `UseItemOn` sent right behind the START. So the use placed against the old block (next to it), and then the old block broke. That is the "appears for a second" case. `ServerPlayerGameMode.handleBlockBreakAction` destroys at once for an instabuild player (`destroyAndAck(pos, sequence, "creative destroy")`). The host now does the same at packet time and clears the dig. Survival STARTs are unchanged. I checked both halves in game. With only the client fix, the diamond block ended up next to the broken stone instead of in its place. With both fixes, it replaces the stone. The in-frame host path (`HORIZON_SERVER_THREAD=0`, deprecated) handles clicks differently and is not changed here. Fixes #3006 ## Kind - [x] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference - `net.minecraft.client.Minecraft.tick`: `pick(1.0F)` (sets `hitResult`), then `handleKeybinds`. `startAttack`, `startUseItem`, `continueAttack` and `pickBlockOrEntity` all read `this.hitResult` (javap of the 26.3 client.jar). - `net.minecraft.server.level.ServerPlayerGameMode.handleBlockBreakAction`: for `getAbilities().instabuild` it calls `destroyAndAck(pos, sequence, "creative destroy")` while handling the packet. - `BlockItem.place` / `BlockPlaceContext`: the clicked block, now air, can be replaced, so the placement goes there. - Test: `interaction_input::tests::attack_and_use_in_one_tick_share_the_hit_result`. Harness: `tools/test_interaction_input_parity.py` still matches the real `handleKeybinds` (its fixture gets no-op hooks). ## Self-check `tools/pr_ready.py` doesn't run on Windows (it needs SIGHUP), so I ran its steps by hand, on the branch rebased onto current `main`: - `cargo fmt --all -- --check`: clean - `cargo clippy -p horizon-client-input --all-targets -- -D warnings`: clean - `cargo clippy -p horizon-client --all-targets -- -D warnings`: clean - `cargo test -p horizon-client-input --lib`: 49 passed - `cargo test -p horizon-client --bin horizon-client -- remote:: lan_actions::`: 7 passed - `python tools/test_interaction_input_parity.py`: 392 cases match the pinned client (1,484 output lines) - New test, run with the two hook calls in `InteractionInput::tick` removed (code only, test kept): `attack_and_use_in_one_tick_share_the_hit_result ... FAILED` ("the use acts on the block the attack broke"). With the calls back: 5 passed. - In game, single player on the server thread, creative, floating stone, diamond block in hand, `mouse left click` + `mouse right click` sent back to back: - Before: the stone broke and nothing was placed (3/3). - Client fix only: the diamond block landed next to the stone's spot. - Both fixes: the diamond block replaced the stone (5/5; `execute if block ... diamond_block` passes on the server). - LAN guest on a second game: the same replace works, and the server agrees. - Some tries placed nothing. In those tries the two ctl commands landed in different client ticks, as with real clicks, and nothing was ever placed next to the stone. The host showed the same split once both windows were throttled to 30 fps. - Regression checks, host and guest: - A creative left click alone breaks the block, and a block set back afterwards stays. - Holding left in creative breaks blocks one after another. - A right click alone still places next to the block. - A survival guest's instant break (dead bush) still works, and a bush set back stays. - `tools/lan_e2e.py --check vehicles --check instant_digging` doesn't start on this Windows machine (`os.symlink` needs a privilege it lacks), so I ran its creative break-and-put-back steps by hand as above. ## Screenshots ![before: both buttons at once leave empty air where the stone was](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/3006-1.png) ![after: the diamond block replaces the stone](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/3006-2.png) Before: in creative with a diamond block in hand, aiming at a floating stone and pressing both buttons leaves empty air where the stone was. After: the same press puts the diamond block exactly where the stone was. 🤖 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-03 05:11:58 +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#5348
No description provided.