Run neighbour and shape updates after landing writes (farmland trampling)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<L: LevelAccess + ?Sized>(
|
||||
&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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user