[PR #3576] [CLOSED] Tools that break while mining play the break sound #5067

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3576
Author: @d3grando
Created: 10/29/2026
Status: ❌ Closed

Base: main ← Head: fix-3524


📝 Commits (1)

  • 2ed0e93 Tools that break while mining play the break sound

📊 Changes

1 file changed (+16 additions, -9 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+16 -9)

📄 Description

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

What and why

Fixes #3524

When a pickaxe (or any tool) wore out while mining a block, it disappeared silently. mine_block_with_held (ItemStack.mineBlock) emptied the slot when the damage reached the maximum, but it skipped two things damage_held (used for attacks, shears, flint and steel...) does: it played no entity.item.break and counted no broken statistic.

Both paths now end in a new held_item_broke, which does what ServerPlayer.onEquippedItemBroken does:

  • awards the item's broken statistic (Stats.ITEM_BROKEN)
  • plays LivingEntity.breakItem's sound: entity.item.break, volume 0.8, pitch 0.8 + nextFloat() * 0.4

On the server thread, that sound reaches the player's client the same way damage_held's does.

Related, not in this PR: #3508 (no break sound on a Paper server). There the server sends entity event 47–52 (LivingEntity.onEquippedItemBroken → broadcastEntityEvent), and Horizon's client doesn't handle those events yet (remote.rs C::EntityEvent). That needs its own change: the client-side breakItem with the item's particles, and the server thread sending the event instead of a sound.

Vanilla reference

  • ItemStack.mineBlock → Item.mineBlock → ItemStack.hurtAndBreak → applyDamage (shrink, then the break callback), then Stats.ITEM_USED
  • ServerPlayer.onEquippedItemBroken (Stats.ITEM_BROKEN) → LivingEntity.onEquippedItemBroken (entityEventForEquipmentBreak: 47 main hand … 52 feet)
  • LivingEntity.handleEntityEvent 47–52 → breakItem: playLocalSound(BREAK_SOUND, 0.8, 0.8 + random.nextFloat() * 0.4) and spawnItemParticles(stack, 5)

Tests

mine_block_with_held is a method on Game, and the binary has no test fixture for a Game. So the test is a scripted in-game run with horizon-ctl, which reads the window's status.heard counts. That count still works with HORIZON_NO_AUDIO=1. The script gives a survival player a wooden_pickaxe[damage=58] (one use left) and mines stone with it:

horizon-ctl command "fill 195 99 516 205 99 532 minecraft:grass_block"
horizon-ctl command "fill 195 100 516 205 104 532 minecraft:air"
horizon-ctl command "setblock 200 101 523 minecraft:stone"
horizon-ctl tp 200.5 100 521.5
horizon-ctl command "gamemode survival"
horizon-ctl command "clear"
horizon-ctl command "give @s minecraft:wooden_pickaxe[damage=58]"
horizon-ctl select 1
horizon-ctl status        # heard before mining
horizon-ctl break 200 101 523
horizon-ctl status        # heard after mining
horizon-ctl inventory     # held after

Before (the code change reverted on the same origin/main base, server thread):

heard before mining {}
{"block":"minecraft:air","block_before":"minecraft:stone",...,"picked_up":{"minecraft:wooden_pickaxe":-1},...}
heard after mining {'minecraft:block.stone.break': 1}
held after None

The pickaxe breaks (picked_up -1), but no minecraft:entity.item.break.

After, server thread:

heard before mining {}
{"block":"minecraft:air","block_before":"minecraft:stone",...,"picked_up":{"minecraft:wooden_pickaxe":-1},...}
heard after mining {'minecraft:block.stone.break': 1, 'minecraft:entity.item.break': 1}
held after None

After, --in-frame:

heard after mining {'minecraft:block.grass.break': 2, 'minecraft:block.stone.break': 1, 'minecraft:entity.item.break': 1}

The sound plays exactly once in both modes.

Self-check

tools/pr_ready.py wasn't run on this Windows machine. I ran these instead, with CARGO_TARGET_DIR set:

  • cargo fmt --all -- --check: clean
  • cargo clippy -p horizon-client --features mods --all-targets -- -D warnings: clean
  • cargo build --profile fast -p horizon-client --features mods --bins, then the in-game script above (server thread and in-frame)

Screenshots

There's nothing to see here; it's a sound. The status.heard counts above are the evidence.

🤖 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/3576 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-3524` --- ### 📝 Commits (1) - [`2ed0e93`](https://github.com/horizon-rust/horizon/commit/2ed0e93584411aabfcf1febe7e6e26aa8376a2df) Tools that break while mining play the break sound ### 📊 Changes **1 file changed** (+16 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+16 -9) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Fixes #3524 When a pickaxe (or any tool) wore out while mining a block, it disappeared silently. `mine_block_with_held` (`ItemStack.mineBlock`) emptied the slot when the damage reached the maximum, but it skipped two things `damage_held` (used for attacks, shears, flint and steel...) does: it played no `entity.item.break` and counted no `broken` statistic. Both paths now end in a new `held_item_broke`, which does what `ServerPlayer.onEquippedItemBroken` does: - awards the item's `broken` statistic (`Stats.ITEM_BROKEN`) - plays `LivingEntity.breakItem`'s sound: `entity.item.break`, volume 0.8, pitch `0.8 + nextFloat() * 0.4` On the server thread, that sound reaches the player's client the same way `damage_held`'s does. Related, not in this PR: #3508 (no break sound on a Paper server). There the server sends entity event 47–52 (`LivingEntity.onEquippedItemBroken` → `broadcastEntityEvent`), and Horizon's client doesn't handle those events yet (`remote.rs` `C::EntityEvent`). That needs its own change: the client-side `breakItem` with the item's particles, and the server thread sending the event instead of a sound. ## Vanilla reference - `ItemStack.mineBlock` → `Item.mineBlock` → `ItemStack.hurtAndBreak` → `applyDamage` (shrink, then the break callback), then `Stats.ITEM_USED` - `ServerPlayer.onEquippedItemBroken` (`Stats.ITEM_BROKEN`) → `LivingEntity.onEquippedItemBroken` (`entityEventForEquipmentBreak`: 47 main hand … 52 feet) - `LivingEntity.handleEntityEvent` 47–52 → `breakItem`: `playLocalSound(BREAK_SOUND, 0.8, 0.8 + random.nextFloat() * 0.4)` and `spawnItemParticles(stack, 5)` ## Tests `mine_block_with_held` is a method on `Game`, and the binary has no test fixture for a `Game`. So the test is a scripted in-game run with `horizon-ctl`, which reads the window's `status.heard` counts. That count still works with `HORIZON_NO_AUDIO=1`. The script gives a survival player a `wooden_pickaxe[damage=58]` (one use left) and mines stone with it: ``` horizon-ctl command "fill 195 99 516 205 99 532 minecraft:grass_block" horizon-ctl command "fill 195 100 516 205 104 532 minecraft:air" horizon-ctl command "setblock 200 101 523 minecraft:stone" horizon-ctl tp 200.5 100 521.5 horizon-ctl command "gamemode survival" horizon-ctl command "clear" horizon-ctl command "give @s minecraft:wooden_pickaxe[damage=58]" horizon-ctl select 1 horizon-ctl status # heard before mining horizon-ctl break 200 101 523 horizon-ctl status # heard after mining horizon-ctl inventory # held after ``` Before (the code change reverted on the same `origin/main` base, server thread): ``` heard before mining {} {"block":"minecraft:air","block_before":"minecraft:stone",...,"picked_up":{"minecraft:wooden_pickaxe":-1},...} heard after mining {'minecraft:block.stone.break': 1} held after None ``` The pickaxe breaks (`picked_up` -1), but no `minecraft:entity.item.break`. After, server thread: ``` heard before mining {} {"block":"minecraft:air","block_before":"minecraft:stone",...,"picked_up":{"minecraft:wooden_pickaxe":-1},...} heard after mining {'minecraft:block.stone.break': 1, 'minecraft:entity.item.break': 1} held after None ``` After, `--in-frame`: ``` heard after mining {'minecraft:block.grass.break': 2, 'minecraft:block.stone.break': 1, 'minecraft:entity.item.break': 1} ``` The sound plays exactly once in both modes. ## Self-check `tools/pr_ready.py` wasn't run on this Windows machine. I ran these instead, with `CARGO_TARGET_DIR` set: - `cargo fmt --all -- --check`: clean - `cargo clippy -p horizon-client --features mods --all-targets -- -D warnings`: clean - `cargo build --profile fast -p horizon-client --features mods --bins`, then the in-game script above (server thread and in-frame) ## Screenshots There's nothing to see here; it's a sound. The `status.heard` counts above are the evidence. 🤖 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:10:00 +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#5067
No description provided.