[PR #1980] [MERGED] Play no place sound when a block item placement is refused #3909

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1980
Author: @kacpherek
Created: 10/25/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @ludovic111

Base: main ← Head: fix/place-sound-refused


📝 Commits (1)

  • e50a4c6 Play no place sound when a block item placement is refused

📊 Changes

1 file changed (+4 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/game/remote.rs (+4 -0)

📄 Description

## What and why

With a torch or a flower in hand, right-clicking a spot where the block can't go (the space is already
taken by a torch or flower, or the clicked face points into an occupied cell) played the block's place
sound in single player on its server thread, though nothing was placed.

After every use the server resends the clicked block and the cell next to it
(ServerGamePacketListenerImpl.handleUseItemOn). The client marked that cell as "placing" on every click,
so the resent state (the torch that was already there) was taken for a fresh placement and its sound
played. Now, when the client predicts no placement for a held block item, it clears the pending place
sound: the placer only hears the placement it predicted itself, as in vanilla.

No issue was filed for this one.

Vanilla reference

  • BlockItem.place: returns InteractionResult.FAIL when BlockPlaceContext.canPlace() is false (or the
    state can't survive) before level.playSound(player, ...), so a refused placement makes no sound.
  • BlockPlaceContext.canPlace: replaceClicked || getBlockState(getClickedPos()).canBeReplaced(this).
  • MultiPlayerGameMode.performUseItemOn: the client runs itemStack.useOn on its own level; the placer's
    sound comes from that prediction (the server's playSound(player, ...) skips the placer).
  • ServerGamePacketListenerImpl.handleUseItemOn: resends pos and pos.relative(direction) after the use.

Checked in game with horizon-ctl (status → heard), on the server thread and --in-frame:

Click place sounds vanilla
torch into the cell holding a torch 0 (was 1) 0
poppy into the cell holding a poppy 0 0
poppy on stone 0 0
torch on free stone 1 1

Harness: test_use_item_on_parity (4000/4000 cases match) covers BlockItem.place on the server side;
this change is the client's handling of the resent block.

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on DESKTOP-H371RFE, against upstream/main at 6df37324f, 4 min 0 s)

Check Result
Scope Ôťů 1 files, +4 Ôłĺ0
Cargo.lock Ôťů unchanged
Public tree Ôťů
Python tests Ô׾ no Python change
rustfmt Ôťů (9 s)
clippy Ôťů (33 s)
tests: horizon-client ÔŁî 1104 passed, 3 failed (3 min 6 s)
doc tests Ôťů 0 passed (9 s)
tokens.css up to date Ô׾ theme untouched
launcher rustfmt Ô׾ launcher untouched
launcher clippy Ô׾ launcher untouched
launcher tests Ô׾ launcher untouched
Parity Ô׾ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The failing horizon-client tests above are the three that fail on Windows on upstream/main as well (crash::tests::stacks_start_at_the_panicking_frame, packs::cache::tests::directory_inputs_config_and_owned_output_recovery, save::tests::session_lock_is_exclusive); every other test passes. CI runs them on Linux.


🔄 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/1980 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/place-sound-refused` --- ### 📝 Commits (1) - [`e50a4c6`](https://github.com/horizon-rust/horizon/commit/e50a4c6443ef1a8dcb997ef79fc47ab759c36f04) Play no place sound when a block item placement is refused ### 📊 Changes **1 file changed** (+4 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/remote.rs` (+4 -0) </details> ### 📄 Description ## What and why With a torch or a flower in hand, right-clicking a spot where the block can't go (the space is already taken by a torch or flower, or the clicked face points into an occupied cell) played the block's place sound in single player on its server thread, though nothing was placed. After every use the server resends the clicked block and the cell next to it (`ServerGamePacketListenerImpl.handleUseItemOn`). The client marked that cell as "placing" on every click, so the resent state (the torch that was already there) was taken for a fresh placement and its sound played. Now, when the client predicts no placement for a held block item, it clears the pending place sound: the placer only hears the placement it predicted itself, as in vanilla. No issue was filed for this one. ## Vanilla reference - `BlockItem.place`: returns `InteractionResult.FAIL` when `BlockPlaceContext.canPlace()` is false (or the state can't survive) before `level.playSound(player, ...)`, so a refused placement makes no sound. - `BlockPlaceContext.canPlace`: `replaceClicked || getBlockState(getClickedPos()).canBeReplaced(this)`. - `MultiPlayerGameMode.performUseItemOn`: the client runs `itemStack.useOn` on its own level; the placer's sound comes from that prediction (the server's `playSound(player, ...)` skips the placer). - `ServerGamePacketListenerImpl.handleUseItemOn`: resends `pos` and `pos.relative(direction)` after the use. Checked in game with `horizon-ctl` (`status` → `heard`), on the server thread and `--in-frame`: | Click | place sounds | vanilla | | --- | ---: | ---: | | torch into the cell holding a torch | 0 (was 1) | 0 | | poppy into the cell holding a poppy | 0 | 0 | | poppy on stone | 0 | 0 | | torch on free stone | 1 | 1 | Harness: `test_use_item_on_parity` (4000/4000 cases match) covers `BlockItem.place` on the server side; this change is the client's handling of the resent block. ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on DESKTOP-H371RFE, against upstream/main at 6df37324f, 4 min 0 s) | Check | Result | | --- | --- | | Scope | Ôťů 1 files, +4 Ôłĺ0 | | Cargo.lock | Ôťů unchanged | | Public tree | Ôťů | | Python tests | Ô׾ no Python change | | rustfmt | Ôťů (9 s) | | clippy | Ôťů (33 s) | | tests: horizon-client | ÔŁî 1104 passed, 3 failed (3 min 6 s) | | doc tests | Ôťů 0 passed (9 s) | | tokens.css up to date | Ô׾ theme untouched | | launcher rustfmt | Ô׾ launcher untouched | | launcher clippy | Ô׾ launcher untouched | | launcher tests | Ô׾ launcher untouched | | Parity | Ô׾ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The failing horizon-client tests above are the three that fail on Windows on upstream/main as well (`crash::tests::stacks_start_at_the_panicking_frame`, `packs::cache::tests::directory_inputs_config_and_owned_output_recovery`, `save::tests::session_lock_is_exclusive`); every other test passes. CI runs them on Linux. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:13: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#3909
No description provided.