[PR #4327] [MERGED] Let a resumed dig run on the START that named the block #5564

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4327
Author: @MSedgeMC
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ludovic111

Base: main ← Head: fix/4124-dig-clock


📝 Commits (7)

  • 84dc805 Let a resumed dig run on the START that named the block
  • 5b8b65a Split the running break from the target, and test the STOP decision
  • 12cbedc Add the dig_clock LAN regression and fix its probe
  • 5035b06 Keep a dig's progress across a missed pick, as vanilla does
  • 73d6388 Write destroyPos only for a dig that takes more than one hit
  • 80443df Fold the destroyPos guard onto one line, as rustfmt wants
  • 8bac188 Keep the remote dig target after a break

📊 Changes

4 files changed (+287 additions, -55 deletions)

View changed files

📝 crates/horizon-client/src/game/lan_actions.rs (+130 -32)
📝 crates/horizon-client/src/game/remote.rs (+64 -21)
📝 tests/test_remote_mining.py (+9 -2)
📝 tools/lan_e2e.py (+84 -0)

📄 Description

Fixes #4124. (Rewritten to describe the final change; the earlier text described the first cut.)

The bug, as vanilla behaves. ServerPlayerGameMode keeps destroyPos and destroyProgressStart when a dig is interrupted — a missed pick, a jump out of reach — so the next STOP_DESTROY_BLOCK for the same block counts every tick since the START. MultiPlayerGameMode.stopDestroyBlock starts with if (!isDestroying) return;, and isDestroying is cleared by a stop while the target survives it. Horizon instead cleared mining on every miss, so a rock you chipped, dropped out of reach of and came back to broke from scratch — and, on the server, the retained clock did not exist at all.

What changed (4 files).

  • game/lan_actions.rs (server): destroy_pos + dig_start are retained across a missed pick, an abort and a respawn, and stop_dig breaks the block with the ticks accumulated since the START, using vanilla's 0.7 split (progress ≥ 0.7 → break; otherwise keep digging, too far, or gone). destroy_pos is now written only in the real-dig branch — after the creative destroy and the instant-mine check — which is where vanilla writes it (this was a review nit).
  • game/remote.rs (client): is_destroying is split from the destroy target, so a stop zeroes the progress without discarding the target, and a resumed dig on the same target neither re-sends a START nor sets is_destroying again.
  • tools/lan_e2e.py: a dig_clock check — host on its server thread, guest chipping a block, jumping out of reach, coming back and finishing — asserting the accumulated ticks rather than a fresh clock (longest single dig 27 ticks against a 100-tick break).
  • tests/test_remote_mining.py: a stub plus an assertion for the retained target, and is_destroying in the stub Remote.

Proven: cargo test -p horizon-client --bin horizon-client a_stop_after_a_fall → 1 passed; python -m unittest tests.test_remote_mining → OK (on a build box, after rebasing onto today's main). By hand on the same box: lan_e2e.py --check dig_clock, dig_stop and instant_digging all PASS, with the guest's longest dig 27 ticks and the clock carried across the miss.

Not proven: no vanilla oracle for this — the behaviour is read from ServerPlayerGameMode / MultiPlayerGameMode bytecode, and the check is a two-game LAN run rather than a parity harness. dig_clock uses a 15-second wall-clock window, so a very slow CI box could make it flaky; the 8-tick threshold has room for the 5-tick apex.

Known overlap: #4394 targets #4124 too, in the same functions. One of the two will conflict; whoever merges second should take it.

Two things a reviewer pointed out that I have deliberately not changed, both harmless today: a guest can wait, swap to a faster tool and send a bare STOP to break the retained block in one packet (gated by may_reach_block), and the client keeps destroying = None after a completed break even though the doc comment says the target outlives the break.


🔄 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/4327 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/4124-dig-clock` --- ### 📝 Commits (7) - [`84dc805`](https://github.com/horizon-rust/horizon/commit/84dc805438a142c89d0efa8c429b4093fd51d8f4) Let a resumed dig run on the START that named the block - [`5b8b65a`](https://github.com/horizon-rust/horizon/commit/5b8b65a1cceda4ef80fe2d1325882943466702e0) Split the running break from the target, and test the STOP decision - [`12cbedc`](https://github.com/horizon-rust/horizon/commit/12cbedcd1be1cb00a3d0750f1ea0e48df92b8c2c) Add the dig_clock LAN regression and fix its probe - [`5035b06`](https://github.com/horizon-rust/horizon/commit/5035b06b97da5bc6bbbf0b5cc9e3315457715131) Keep a dig's progress across a missed pick, as vanilla does - [`73d6388`](https://github.com/horizon-rust/horizon/commit/73d6388a0eb46be76d1ef7bd8a0b9c369ee3a13f) Write destroyPos only for a dig that takes more than one hit - [`80443df`](https://github.com/horizon-rust/horizon/commit/80443df31ee71d1fc68a8ab732595bddfc54580a) Fold the destroyPos guard onto one line, as rustfmt wants - [`8bac188`](https://github.com/horizon-rust/horizon/commit/8bac1883f2cc8e66bf8edddbf1fd56e9212bdded) Keep the remote dig target after a break ### 📊 Changes **4 files changed** (+287 additions, -55 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan_actions.rs` (+130 -32) 📝 `crates/horizon-client/src/game/remote.rs` (+64 -21) 📝 `tests/test_remote_mining.py` (+9 -2) 📝 `tools/lan_e2e.py` (+84 -0) </details> ### 📄 Description Fixes #4124. (Rewritten to describe the final change; the earlier text described the first cut.) **The bug, as vanilla behaves.** `ServerPlayerGameMode` keeps `destroyPos` and `destroyProgressStart` when a dig is interrupted — a missed pick, a jump out of reach — so the next `STOP_DESTROY_BLOCK` for the same block counts every tick since the START. `MultiPlayerGameMode.stopDestroyBlock` starts with `if (!isDestroying) return;`, and `isDestroying` is cleared by a stop while the target survives it. Horizon instead cleared `mining` on every miss, so a rock you chipped, dropped out of reach of and came back to broke from scratch — and, on the server, the retained clock did not exist at all. **What changed (4 files).** - `game/lan_actions.rs` (server): `destroy_pos` + `dig_start` are retained across a missed pick, an abort and a respawn, and `stop_dig` breaks the block with the ticks accumulated since the START, using vanilla's 0.7 split (progress ≥ 0.7 → break; otherwise keep digging, too far, or gone). `destroy_pos` is now written only in the real-dig branch — after the creative destroy and the instant-mine check — which is where vanilla writes it (this was a review nit). - `game/remote.rs` (client): `is_destroying` is split from the destroy target, so a stop zeroes the progress without discarding the target, and a resumed dig on the same target neither re-sends a START nor sets `is_destroying` again. - `tools/lan_e2e.py`: a `dig_clock` check — host on its server thread, guest chipping a block, jumping out of reach, coming back and finishing — asserting the accumulated ticks rather than a fresh clock (longest single dig 27 ticks against a 100-tick break). - `tests/test_remote_mining.py`: a stub plus an assertion for the retained target, and `is_destroying` in the stub `Remote`. **Proven:** `cargo test -p horizon-client --bin horizon-client a_stop_after_a_fall` → 1 passed; `python -m unittest tests.test_remote_mining` → OK (on a build box, after rebasing onto today's `main`). By hand on the same box: `lan_e2e.py --check dig_clock`, `dig_stop` and `instant_digging` all PASS, with the guest's longest dig 27 ticks and the clock carried across the miss. **Not proven:** no vanilla oracle for this — the behaviour is read from `ServerPlayerGameMode` / `MultiPlayerGameMode` bytecode, and the check is a two-game LAN run rather than a parity harness. `dig_clock` uses a 15-second wall-clock window, so a very slow CI box could make it flaky; the 8-tick threshold has room for the 5-tick apex. **Known overlap:** #4394 targets #4124 too, in the same functions. One of the two will conflict; whoever merges second should take it. Two things a reviewer pointed out that I have deliberately not changed, both harmless today: a guest can wait, swap to a faster tool and send a bare STOP to break the retained block in one packet (gated by `may_reach_block`), and the client keeps `destroying = None` after a completed break even though the doc comment says the target outlives the break. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:13:25 +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#5564
No description provided.