diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 989123384..490a8a896 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -1386,6 +1386,13 @@ impl Game<'_> { }; self.audio.play(name, Some(feet), volume, pitch); } + MotionEvent::Fall(horizon_client::landing::FallEvent::Write { position, flags, .. }) => { + // Landing rules (farmland trampling, turtle eggs) wrote the block raw. + self.with_level(|b, level, ticks| b.notify_written(level, ticks, position, flags as i32)); + } + MotionEvent::Fall(horizon_client::landing::FallEvent::Destroy { position, .. }) => { + self.with_level(|b, level, ticks| b.notify_written(level, ticks, position, level_flags::UPDATE_ALL)); + } MotionEvent::Fall(horizon_client::landing::FallEvent::Damage { .. }) => { self.audio.play("minecraft:entity.player.hurt", Some(feet), 1.0, 1.0); } diff --git a/crates/horizon-world/src/level/signals.rs b/crates/horizon-world/src/level/signals.rs index 6f02ff549..95b7130d7 100644 --- a/crates/horizon-world/src/level/signals.rs +++ b/crates/horizon-world/src/level/signals.rs @@ -19,3 +19,27 @@ impl Behaviours { } } } + +impl Behaviours { + /// The update half of `Level.setBlock` for a state the caller already + /// wrote to storage (entity landing rules write blocks directly): + /// neighbour updates, then neighbour shape updates, per `flags`. + pub fn notify_written( + &self, + level: &mut L, + ticks: &mut Ticks, + pos: BlockPos, + flags: i32, + ) { + use super::flags as f; + let state = level.block_state(pos); + let mut sim = self.sim(level, ticks); + if flags & f::UPDATE_NEIGHBORS != 0 { + sim.update_neighbors_at(pos, self.block(state)); + } + if flags & f::UPDATE_KNOWN_SHAPE == 0 { + let neighbour_flags = flags & !(f::UPDATE_NEIGHBORS | f::UPDATE_SUPPRESS_DROPS); + sim.update_neighbour_shapes(state, pos, neighbour_flags, f::UPDATE_LIMIT - 1); + } + } +}