From 0d3ca74bd00844548a198c49bb5e3d02ecb74aa1 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 22:33:01 +0100 Subject: [PATCH] Break turtle eggs by stepping on them TurtleEggBlock.stepOn calls destroyEgg(100) for any step that is not careful; only the fall path (1 in 3) existed. --- crates/horizon-client/src/motion.rs | 13 +++ crates/horizon-world/src/block_landing.rs | 97 +++++++++++++++-------- 2 files changed, 75 insertions(+), 35 deletions(-) diff --git a/crates/horizon-client/src/motion.rs b/crates/horizon-client/src/motion.rs index e9899ad40..535e89292 100644 --- a/crates/horizon-client/src/motion.rs +++ b/crates/horizon-client/src/motion.rs @@ -1257,6 +1257,19 @@ impl MotionWorld<'_, '_, '_> { if magma && !self.player.shift_key_down { self.environment_hurt("minecraft:hot_floor", 1.0)?; } + // TurtleEggBlock.stepOn: a step that is not careful may break an egg. + if !self.player.shift_key_down { + let state = self.block(on); + self.resources + .landing + .step_on( + self, + state, + on, + horizon_world::block_landing::LandingEntityKind::Player, + ) + .map_err(|e| e.to_string())?; + } // SlimeBlock.stepOn: a slow walk on slime drags the horizontal // speed (the client moves its own player, so not the server's copy). if slime && !damage_only && !self.player.shift_key_down { diff --git a/crates/horizon-world/src/block_landing.rs b/crates/horizon-world/src/block_landing.rs index ebcd78e29..60f5296d8 100644 --- a/crates/horizon-world/src/block_landing.rs +++ b/crates/horizon-world/src/block_landing.rs @@ -266,6 +266,66 @@ impl BlockLandingRegistry { } Ok(()) } + /// `TurtleEggBlock.stepOn`: a step that is not careful breaks an egg one + /// time in 100. + pub fn step_on( + &self, + world: &mut W, + state: BlockStateId, + position: BlockPos, + entity: LandingEntityKind, + ) -> Result<(), LandingError> { + if let Rule::TurtleEgg { remaining } = self.state(state)?.rule { + self.destroy_egg(world, remaining, state, position, entity, 100)?; + } + Ok(()) + } + /// `TurtleEggBlock.destroyEgg`: one egg breaks with chance 1 in `randomness`. + fn destroy_egg( + &self, + world: &mut W, + remaining: Option, + state: BlockStateId, + position: BlockPos, + entity: LandingEntityKind, + randomness: i32, + ) -> Result<(), LandingError> { + if !world.is_server_level() + || matches!(entity, LandingEntityKind::Turtle | LandingEntityKind::Bat) + { + return Ok(()); + } + let allowed = if entity == LandingEntityKind::Player { + !world + .under_spawn_protection(position) + .map_err(LandingError::World)? + } else { + entity.living() && world.mob_griefing().map_err(LandingError::World)? + }; + if allowed && world.random_int(randomness).map_err(LandingError::World)? == 0 { + let sound = world.known_sound(LandingSound::TurtleEggBreak); + let pitch = 0.9f32 + world.random_float().map_err(LandingError::World)? * 0.2f32; + world + .block_sound(position, sound, 0.7, pitch) + .map_err(LandingError::World)?; + if let Some(next) = remaining { + world + .set_block(position, next, 2) + .map_err(LandingError::World)?; + world + .block_event(LandingEvent::BlockDestroy, position, state, false) + .map_err(LandingError::World)?; + world + .level_event(2001, position, state.0 as i32) + .map_err(LandingError::World)?; + } else { + world + .destroy_block(position, false) + .map_err(LandingError::World)?; + } + } + Ok(()) + } pub fn fall_on( &self, world: &mut W, @@ -373,41 +433,8 @@ impl BlockLandingRegistry { } } Rule::TurtleEgg { remaining } => { - if !matches!( - entity, - LandingEntityKind::Zombie | LandingEntityKind::Turtle | LandingEntityKind::Bat - ) && world.is_server_level() - { - let allowed = if entity == LandingEntityKind::Player { - !world - .under_spawn_protection(position) - .map_err(LandingError::World)? - } else { - entity.living() && world.mob_griefing().map_err(LandingError::World)? - }; - if allowed && world.random_int(3).map_err(LandingError::World)? == 0 { - let sound = world.known_sound(LandingSound::TurtleEggBreak); - let pitch = - 0.9f32 + world.random_float().map_err(LandingError::World)? * 0.2f32; - world - .block_sound(position, sound, 0.7, pitch) - .map_err(LandingError::World)?; - if let Some(next) = remaining { - world - .set_block(position, next, 2) - .map_err(LandingError::World)?; - world - .block_event(LandingEvent::BlockDestroy, position, state, false) - .map_err(LandingError::World)?; - world - .level_event(2001, position, state.0 as i32) - .map_err(LandingError::World)?; - } else { - world - .destroy_block(position, false) - .map_err(LandingError::World)?; - } - } + if entity != LandingEntityKind::Zombie { + self.destroy_egg(world, remaining, state, position, entity, 3)?; } } }