[PR #1587] [MERGED] Predict block placement on the client, so fast bridging stops losing clicks #3614

Closed
opened 2026-11-03 04:10:48 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1587
Author: @levzzz5154
Created: 10/24/2026
Status: ✅ Merged
Merged: 10/25/2026
Merged by: @ludovic111

Base: main ← Head: fix/predict-block-placement


📝 Commits (3)

  • 352645b Predict block placement on the client, so fast bridging stops losing clicks
  • 90b5e16 Play a placed block's sound once for its placer
  • 3f1a7b2 Placement prediction: one helper for predicted blocks, the sound where the block went

📊 Changes

2 files changed (+91 additions, -34 deletions)

View changed files

📝 crates/horizon-client/src/game/lan_actions.rs (+26 -0)
📝 crates/horizon-client/src/game/remote.rs (+65 -34)

📄 Description

🤖 Opened by levzzz's AI agent (Claude Code), not by levzzz themself.

Bridging fast as a server client (single player on the server thread, LAN guests, dedicated servers) sometimes lost a block: the arm swung, but nothing was placed on the client or the server.

Cause: the client never predicted block placement. It sent UseItemOn and swung if a dry run of BlockItem.place succeeded, but the block only appeared when the server's BlockUpdate arrived. A click made before that aimed past the missing block, at the face of the block behind it. The server already had a block at that target, so it refused the click.

Fix: as in vanilla's MultiPlayerGameMode.useItemOn inside startPrediction, the blocks the dry run set are placed on the client's level at once. Each is kept as predicted under the use's sequence (retainKnownServerState) until BlockChangedAck, which settles it on the server's state. A placement the server refuses goes back. The held stack shrinks locally too (ItemStack.consume; the server's slot update confirms it). Hand-operated blocks and breaks already worked this way.

Tested by hand with horizon-ctl, in survival on the server thread: four right-clicks build a chain of blocks, each click aiming at the face of the block the previous click placed. Blocks were counted after the server's ack.

Gap between clicks Before After
60 ms 4 of 4 4 of 4
20 ms 3 of 4 4 of 4
0 ms – 4 of 4 (64 → 60 in the stack)

In-frame single player is unchanged: it places on its own level.

Harnesses: level_place, placement, use_item_on, server_entities, server_player_targets, dedicated_server pass.

pr_ready --quick: Python tests, rustfmt, clippy, workspace tests (1930), doc tests and launcher checks all ✅. Parity: 326 affected, left to CI. (The scope line counted against the fork's stale main. Against upstream, the change is one file, +46 −10.)

🤖 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/1587 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/24/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/predict-block-placement` --- ### 📝 Commits (3) - [`352645b`](https://github.com/horizon-rust/horizon/commit/352645b41711436306bc30e41e139b2d3809005a) Predict block placement on the client, so fast bridging stops losing clicks - [`90b5e16`](https://github.com/horizon-rust/horizon/commit/90b5e162ae0f586d9494a68a86319400bb75db9c) Play a placed block's sound once for its placer - [`3f1a7b2`](https://github.com/horizon-rust/horizon/commit/3f1a7b28af0ba3fac58ad43194d06912ae969cd0) Placement prediction: one helper for predicted blocks, the sound where the block went ### 📊 Changes **2 files changed** (+91 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan_actions.rs` (+26 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+65 -34) </details> ### 📄 Description > 🤖 Opened by levzzz's AI agent (Claude Code), not by levzzz themself. Bridging fast as a server client (single player on the server thread, LAN guests, dedicated servers) sometimes lost a block: the arm swung, but nothing was placed on the client or the server. **Cause:** the client never predicted block placement. It sent `UseItemOn` and swung if a dry run of `BlockItem.place` succeeded, but the block only appeared when the server's `BlockUpdate` arrived. A click made before that aimed past the missing block, at the face of the block behind it. The server already had a block at that target, so it refused the click. **Fix:** as in vanilla's `MultiPlayerGameMode.useItemOn` inside `startPrediction`, the blocks the dry run set are placed on the client's level at once. Each is kept as predicted under the use's sequence (`retainKnownServerState`) until `BlockChangedAck`, which settles it on the server's state. A placement the server refuses goes back. The held stack shrinks locally too (`ItemStack.consume`; the server's slot update confirms it). Hand-operated blocks and breaks already worked this way. **Tested** by hand with horizon-ctl, in survival on the server thread: four right-clicks build a chain of blocks, each click aiming at the face of the block the previous click placed. Blocks were counted after the server's ack. | Gap between clicks | Before | After | |---|---|---| | 60 ms | 4 of 4 | 4 of 4 | | 20 ms | 3 of 4 | 4 of 4 | | 0 ms | – | 4 of 4 (64 → 60 in the stack) | In-frame single player is unchanged: it places on its own level. Harnesses: `level_place`, `placement`, `use_item_on`, `server_entities`, `server_player_targets`, `dedicated_server` pass. **pr_ready --quick:** Python tests, rustfmt, clippy, workspace tests (1930), doc tests and launcher checks all ✅. Parity: 326 affected, left to CI. (The scope line counted against the fork's stale main. Against upstream, the change is one file, +46 −10.) 🤖 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 04:10:48 +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#3614
No description provided.