From 4ce1eb6b0a8561769d4fd37f22c6f106304481ed Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 22:36:42 +0100 Subject: [PATCH] Play the crossbow hit sound for arrows shot from a crossbow CrossbowItem.createProjectile sets the arrow's sound event to item.crossbow.hit; every arrow hit played entity.arrow.hit. --- crates/horizon-client/examples/probe/arrow_probe.rs | 1 + crates/horizon-client/src/arrows.rs | 10 ++++++++++ crates/horizon-client/src/game/creatures.rs | 1 + 3 files changed, 12 insertions(+) diff --git a/crates/horizon-client/examples/probe/arrow_probe.rs b/crates/horizon-client/examples/probe/arrow_probe.rs index 411561c4e..eca28f1f5 100644 --- a/crates/horizon-client/examples/probe/arrow_probe.rs +++ b/crates/horizon-client/examples/probe/arrow_probe.rs @@ -161,6 +161,7 @@ pub fn main() -> Result<()> { "sound {} {:08x} {:08x}", match sound { ArrowSound::HitGround => "hit", + ArrowSound::CrossbowHit => "crossbow_hit", ArrowSound::Splash => "splash", ArrowSound::Extinguish => "extinguish", ArrowSound::TridentHitGround => "trident_hit_ground", diff --git a/crates/horizon-client/src/arrows.rs b/crates/horizon-client/src/arrows.rs index 9b46269ad..c3269831f 100644 --- a/crates/horizon-client/src/arrows.rs +++ b/crates/horizon-client/src/arrows.rs @@ -130,6 +130,8 @@ pub enum ArrowSound { Splash, /// The arrow's `soundEvent` (`entity.arrow.hit`), for blocks and entities. HitGround, + /// An arrow shot from a crossbow: `item.crossbow.hit`. + CrossbowHit, /// `entity.generic.extinguish_fire`. Extinguish, /// A thrown trident's `getDefaultHitGroundSoundEvent` (`item.trident.hit_ground`). @@ -782,8 +784,16 @@ impl Ticker<'_, '_, '_, '_> { /// `playSound(soundEvent, 1, 1.2 / (random * 0.2 + 0.9))`. fn hit_sound(&mut self) { let pitch = 1.2 / (self.st.random.next_float() * 0.2 + 0.9); + // CrossbowItem.createProjectile: its arrows hit with the crossbow's sound. + let crossbow = self + .st + .fired_from_weapon + .as_ref() + .is_some_and(|s| &*s.item == "minecraft:crossbow"); let sound = if self.trident() { ArrowSound::TridentHitGround + } else if crossbow { + ArrowSound::CrossbowHit } else { ArrowSound::HitGround }; diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index 090f373b5..53b1ca29b 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -2565,6 +2565,7 @@ impl Game<'_> { let name = match sound { ArrowSound::Splash => "minecraft:entity.generic.splash", ArrowSound::HitGround => "minecraft:entity.arrow.hit", + ArrowSound::CrossbowHit => "minecraft:item.crossbow.hit", ArrowSound::Extinguish => "minecraft:entity.generic.extinguish_fire", ArrowSound::TridentHitGround => "minecraft:item.trident.hit_ground", ArrowSound::TridentHit => "minecraft:item.trident.hit",