From 66637220efc12e298a565d7d569c689f8442e1d0 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 15:13:58 +0100 Subject: [PATCH] Play the step sound of the block above the floor for the player Powder snow, lily pads, carpets, snow layers and similar blocks now sound like vanilla when walked on: inside blocks replace the floor's step, combination blocks play their own step with the floor's step muffled. --- .../examples/probe/scene_motion_probe.rs | 2 +- crates/horizon-client/src/game.rs | 6 +-- crates/horizon-client/src/game/remote.rs | 8 +-- crates/horizon-client/src/motion.rs | 51 ++++++++++++++++--- 4 files changed, 52 insertions(+), 15 deletions(-) diff --git a/crates/horizon-client/examples/probe/scene_motion_probe.rs b/crates/horizon-client/examples/probe/scene_motion_probe.rs index 21977eeab..67b2e1560 100644 --- a/crates/horizon-client/examples/probe/scene_motion_probe.rs +++ b/crates/horizon-client/examples/probe/scene_motion_probe.rs @@ -206,7 +206,7 @@ fn snapshot(out: &mut impl Write, player: &PlayerMotion) -> Result<()> { )), MotionEvent::Emission { state, - in_water: true, + muffled: true, .. } => Some(format!("muffled-step {}", state.0)), MotionEvent::BubbleColumnParticle { bubble, position } => Some(format!( diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 1d86fe990..f2f12d802 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -4349,13 +4349,11 @@ impl Game<'_> { for event in events { match event { MotionEvent::HurtSound(sound) => self.player_hurt_sound(sound, feet), - MotionEvent::Emission { - state, in_water, .. - } if !crouching => { + MotionEvent::Emission { state, muffled, .. } if !crouching => { let sounds = self.res.facts().get(state).sounds.clone(); // Entity.playStepSound: the block's step sound at 0.15 volume, // muffled under the swim sound in water. - let (volume, pitch) = if in_water { + let (volume, pitch) = if muffled { (sounds.volume * 0.05, sounds.pitch * 0.8) } else { (sounds.volume * 0.15, sounds.pitch) diff --git a/crates/horizon-client/src/game/remote.rs b/crates/horizon-client/src/game/remote.rs index 857f955da..f5365034a 100644 --- a/crates/horizon-client/src/game/remote.rs +++ b/crates/horizon-client/src/game/remote.rs @@ -3233,12 +3233,12 @@ impl Game<'_> { let feet = [player.position.x, player.position.y, player.position.z]; for event in events { match event { - horizon_client::motion::MotionEvent::Emission { - state, in_water, .. - } if !crouching => { + horizon_client::motion::MotionEvent::Emission { state, muffled, .. } + if !crouching => + { let sounds = self.res.facts().get(state).sounds.clone(); // Player.playStepSound: muffled under the swim sound in water. - let (volume, pitch) = if in_water { + let (volume, pitch) = if muffled { (sounds.volume * 0.05, sounds.pitch * 0.8) } else { (sounds.volume * 0.15, sounds.pitch) diff --git a/crates/horizon-client/src/motion.rs b/crates/horizon-client/src/motion.rs index 0bce8927c..1f788fb50 100644 --- a/crates/horizon-client/src/motion.rs +++ b/crates/horizon-client/src/motion.rs @@ -51,6 +51,10 @@ pub struct MotionResources { pub blocks: BoundMovementProperties, pub climbable: BTreeSet, pub fall_reset: BTreeSet, + /// `BlockTags.INSIDE_STEP_SOUND_BLOCKS`. + pub inside_step_sound: BTreeSet, + /// `BlockTags.COMBINATION_STEP_SOUND_BLOCKS`. + pub combination_step_sound: BTreeSet, pub landing: BlockLandingRegistry, pub health: crate::health::HealthResources, pub fluids: FluidResources, @@ -109,6 +113,8 @@ impl MotionResources { })?, climbable: tag("minecraft:climbable")?, fall_reset: tag("minecraft:fall_damage_resetting")?, + inside_step_sound: tag("minecraft:inside_step_sound_blocks")?, + combination_step_sound: tag("minecraft:combination_step_sound_blocks")?, }) } } @@ -136,11 +142,12 @@ pub enum MotionEvent { position: BlockPos, }, /// `Entity.walkingStepSound` on this block: `Player.playStepSound` - /// muffles it under a swim sound when `in_water`. + /// mutes it (`playMuffledStepSound`) under a swim sound in water or + /// under a combination block's own step. Emission { position: BlockPos, state: BlockStateId, - in_water: bool, + muffled: bool, }, /// `Entity.waterSwimSound`: `entity.player.swim`. Swim { @@ -1973,16 +1980,48 @@ impl MovementEmissionWorld for MotionWorld<'_, '_, '_> { fn in_water(&mut self) -> Result { Ok(self.player.fluids.was_touching_water) } - /// `Player.playStepSound`: in water a swim sound, then the step muffled. + /// `Player.playStepSound`: in water a swim sound, then the step muffled; + /// on land the step of an inside-sound block above the floor, or of a + /// combination block above it with the floor's step muffled. fn walking_step_sound(&mut self, position: BlockPos, state: BlockStateId) -> Result<()> { - let in_water = self.player.fluids.was_touching_water; - if in_water { + let muffled = self.player.fluids.was_touching_water; + if muffled { self.water_swim_sound()?; + } else { + // Entity.getPrimaryStepSoundBlockPos. + let above = BlockPos { + y: position.y + 1, + ..position + }; + let above_state = self.block(above); + let name = &self + .assets + .registry + .state(above_state) + .ok_or("missing scene state")? + .name; + let combination = self.resources.combination_step_sound.contains(name); + if combination || self.resources.inside_step_sound.contains(name) { + self.player.events.push(MotionEvent::Emission { + position: above, + state: above_state, + muffled: false, + }); + if combination { + // Entity.playCombinationStepSounds. + self.player.events.push(MotionEvent::Emission { + position, + state, + muffled: true, + }); + } + return Ok(()); + } } self.player.events.push(MotionEvent::Emission { position, state, - in_water, + muffled, }); Ok(()) }