[PR #2732] [MERGED] Cover the mining sound cadence in the LAN harness #4576

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2732
Author: @levzzz5154
Created: 10/27/2026
Status: ✅ Merged
Merged: 10/28/2026
Merged by: @ludovic111

Base: main ← Head: fix/mining-hit-sound


📝 Commits (2)

  • 9ebccd6 Cover the mining sound cadence in the LAN harness
  • fcc7a81 Merge remote-tracking branch 'upstream/main' into fix/mining-hit-sound

📊 Changes

2 files changed (+57 additions, -4 deletions)

View changed files

📝 tests/test_remote_mining.py (+17 -4)
📝 tools/lan_e2e.py (+40 -0)

📄 Description

🤖 Opened by levzzz5154's AI agent (Claude Code), not by levzzz5154 himself.

What and why

#2277 reports the wood breaking sound as "played too often and it sounds strange". The
cause was two playbacks of the same event: the digger's own client played the block's
hit sound every fourth tick of the dig, and the server played it too (through the
hub's guest simulation, and the sound packet it sent to the guests), so the digger
heard every hit twice — the two a tick or two apart, with different random pitches,
which is what makes it sound wrong. The players around heard only the server's copy.

The fix for that landed in #2350: the hit sound now comes from the server's destroy
progress level events (2019 and 2020), which vanilla sends to everyone, and the
client plays it only once, when the dig starts. This pull request adds the missing
regression coverage, so the double playback cannot come back:

  • tools/lan_e2e.py, the new dig_sounds check: the host and the guest each hold
    the attack on a stone block for 40 ticks, and the check compares the block.stone.hit
    sounds each side counted. The digger must not hear more hits than the player
    standing next to it.
  • tests/test_remote_mining.py: the fixture now records the sounds the client plays,
    and asserts that a dig plays the hit sound once, when it starts, and never in the
    loop.

The check fails on the tree before #2350 (the digger counted 20 hits against the 10 the
player nearby heard) and passes on the current main (11 against 10: the digger's own
start sound, then the server's hits).

Fixes #2277

Vanilla reference

  • net.minecraft.client.multiplayer.MultiPlayerGameMode.startDestroyBlock — when the
    dig starts it calls ClientLevel.addBreakingBlockEffects(destroyBlockPos, destroyDirection, true), which plays the block's hit sound once; the loop
    (continueDestroyBlock) plays no sound at all.
  • net.minecraft.client.multiplayer.ClientLevel.addBreakingBlockEffects — the hit
    sound (playBreakingSound) when playSound is set, and the breaking particles on
    the face being mined.
  • net.minecraft.server.level.ServerPlayerGameMode.tick — while the player digs it
    computes ticksSpentDestroying = gameTicks - destroyProgressStart and sends
    levelEvent(null, ticksSpentDestroying % 4 == 0 ? 2020 : 2019, destroyPos, destroyDirection.ordinal()): the crack every tick, the hit sound every fourth one.
  • net.minecraft.server.level.ServerLevel.levelEvent — the null source broadcasts
    the event to every player, the digger included, so the digger and the players around
    hear the same hits.

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on cachyos-x8664, against upstream/main at 6817cb4af, 18 s)

Check Result
Scope ✅ 2 files, +57 −4
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 331 passed (18 s)
rustfmt ➖ no Rust change
clippy ➖ no Rust change
tests ➖ no crate touched
doc tests ➖ no crate touched
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 15 affected, to run in CI (--quick): forced_end, lan_integration, remote_fireball, remote_fireworks, save_roundtrip, server_dimension_players, server_dragon, server_knockback, server_ops_feedback, server_player_sculk, server_resource_pack, spawn_loot and 3 more
Label skip-release
  • HORIZON_E2E_HEADLESS=1 python3 tools/lan_e2e.py --bin-dir /home/levzzz/Documents/horizon/target/fast --check dig_sounds --check dig_stop —
    [lan] dig_sounds: PASS {'host': {'host': 11, 'guest': 10}, 'guest': {'host': 10, 'guest': 11}} and [lan] dig_stop: PASS (the check that came with the fix still
    passes).
  • The same dig_sounds check on the tree before #2350 (git stash of the client
    changes, rebuilt): [lan] dig_sounds: FAIL AssertionError("host: the digger heard the mining sound twice: {'host': {'host': 20, 'guest': 10}}") — the digger heard
    every hit twice, the player nearby once.
  • python3 -m unittest tests.test_remote_mining — OK (1 test). Without the fix the
    fixture's new assertion fails: the client plays the hit sound in the loop.
  • cargo build --locked --profile fast -p horizon-client --bin horizon-client --bin horizon-ctl — builds clean (the one warning, an unreachable minecraft:rabbit
    pattern, is already on main).

🤖 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/2732 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/28/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/mining-hit-sound` --- ### 📝 Commits (2) - [`9ebccd6`](https://github.com/horizon-rust/horizon/commit/9ebccd6a5948a739e538abe4b2130c3dec29e836) Cover the mining sound cadence in the LAN harness - [`fcc7a81`](https://github.com/horizon-rust/horizon/commit/fcc7a818b40e698bf919bc15a9b1999eece45cff) Merge remote-tracking branch 'upstream/main' into fix/mining-hit-sound ### 📊 Changes **2 files changed** (+57 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_remote_mining.py` (+17 -4) 📝 `tools/lan_e2e.py` (+40 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code), not by levzzz5154 himself. ## What and why #2277 reports the wood breaking sound as "played too often and it sounds strange". The cause was two playbacks of the same event: the digger's own client played the block's hit sound every fourth tick of the dig, and the server played it too (through the hub's guest simulation, and the sound packet it sent to the guests), so the digger heard every hit twice — the two a tick or two apart, with different random pitches, which is what makes it sound wrong. The players around heard only the server's copy. The fix for that landed in #2350: the hit sound now comes from the server's destroy progress level events (2019 and 2020), which vanilla sends to everyone, and the client plays it only once, when the dig starts. This pull request adds the missing regression coverage, so the double playback cannot come back: * `tools/lan_e2e.py`, the new `dig_sounds` check: the host and the guest each hold the attack on a stone block for 40 ticks, and the check compares the `block.stone.hit` sounds each side counted. The digger must not hear more hits than the player standing next to it. * `tests/test_remote_mining.py`: the fixture now records the sounds the client plays, and asserts that a dig plays the hit sound once, when it starts, and never in the loop. The check fails on the tree before #2350 (the digger counted 20 hits against the 10 the player nearby heard) and passes on the current main (11 against 10: the digger's own start sound, then the server's hits). Fixes #2277 ## Vanilla reference * `net.minecraft.client.multiplayer.MultiPlayerGameMode.startDestroyBlock` — when the dig starts it calls `ClientLevel.addBreakingBlockEffects(destroyBlockPos, destroyDirection, true)`, which plays the block's hit sound once; the loop (`continueDestroyBlock`) plays no sound at all. * `net.minecraft.client.multiplayer.ClientLevel.addBreakingBlockEffects` — the hit sound (`playBreakingSound`) when `playSound` is set, and the breaking particles on the face being mined. * `net.minecraft.server.level.ServerPlayerGameMode.tick` — while the player digs it computes `ticksSpentDestroying = gameTicks - destroyProgressStart` and sends `levelEvent(null, ticksSpentDestroying % 4 == 0 ? 2020 : 2019, destroyPos, destroyDirection.ordinal())`: the crack every tick, the hit sound every fourth one. * `net.minecraft.server.level.ServerLevel.levelEvent` — the `null` source broadcasts the event to every player, the digger included, so the digger and the players around hear the same hits. ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on cachyos-x8664, against upstream/main at 6817cb4af, 18 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +57 −4 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 331 passed (18 s) | | rustfmt | ➖ no Rust change | | clippy | ➖ no Rust change | | tests | ➖ no crate touched | | doc tests | ➖ no crate touched | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 15 affected, to run in CI (--quick): forced_end, lan_integration, remote_fireball, remote_fireworks, save_roundtrip, server_dimension_players, server_dragon, server_knockback, server_ops_feedback, server_player_sculk, server_resource_pack, spawn_loot and 3 more | | Label | `skip-release` | * `HORIZON_E2E_HEADLESS=1 python3 tools/lan_e2e.py --bin-dir /home/levzzz/Documents/horizon/target/fast --check dig_sounds --check dig_stop` — `[lan] dig_sounds: PASS {'host': {'host': 11, 'guest': 10}, 'guest': {'host': 10, 'guest': 11}}` and `[lan] dig_stop: PASS` (the check that came with the fix still passes). * The same `dig_sounds` check on the tree before #2350 (`git stash` of the client changes, rebuilt): `[lan] dig_sounds: FAIL AssertionError("host: the digger heard the mining sound twice: {'host': {'host': 20, 'guest': 10}}")` — the digger heard every hit twice, the player nearby once. * `python3 -m unittest tests.test_remote_mining` — `OK` (1 test). Without the fix the fixture's new assertion fails: the client plays the hit sound in the loop. * `cargo build --locked --profile fast -p horizon-client --bin horizon-client --bin horizon-ctl` — builds clean (the one warning, an unreachable `minecraft:rabbit` pattern, is already on main). 🤖 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:18:11 +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#4576
No description provided.