From 753a99b933605a8c3feea789ba36f333a203d3f7 Mon Sep 17 00:00:00 2001 From: rdbtCVS <87152661+rdbtCVS@users.noreply.github.com> Date: Sun, 25 Oct 2026 02:55:30 +0000 Subject: [PATCH 1/2] Fix crop updates after server-side farmland trampling Forward landing block-write events to notify_written so unsupported crops break, drop their items, and synchronize to clients. Add LAN regression coverage for the host and guest in both hosting paths. Co-Authored-By: OpenCode GPT-6.1-sol --- crates/horizon-client/src/game/lan_actions.rs | 30 ++++---- tools/lan_e2e.py | 69 +++++++++++++++++++ 2 files changed, 87 insertions(+), 12 deletions(-) diff --git a/crates/horizon-client/src/game/lan_actions.rs b/crates/horizon-client/src/game/lan_actions.rs index 58ed97c2f..21cb7dcf4 100644 --- a/crates/horizon-client/src/game/lan_actions.rs +++ b/crates/horizon-client/src/game/lan_actions.rs @@ -1939,7 +1939,7 @@ impl Game<'_> { let in_wall = !g.sleeping && self.in_wall(g.position, g.eye_height()); let at = g.position; let sneaking = g.sneaking; - let sounds = self.as_guest(host, conn, |game| { + let events = self.as_guest(host, conn, |game| { let (rules, motion) = (game.world.health_rules, game.motion); let health = &motion.health; let Some(player) = game.player.as_mut() else { @@ -2036,20 +2036,26 @@ impl Game<'_> { // A hurt since the last tick marked the velocity (Entity.markHurt): // ServerEntity.sendChanges sends it as it is after this travel. let marked = std::mem::take(&mut player.health.sync_velocity); - let sounds = events - .into_iter() - .filter_map(|e| match e { - MotionEvent::HurtSound(sound) => Some(sound), - _ => None, - }) - .collect::>(); - (sounds, marked.then_some(player.velocity)) + (events, marked.then_some(player.velocity)) }); - let Some((sounds, marked)) = sounds else { + let Some((events, marked)) = events else { return; }; - for sound in sounds { - self.player_hurt_sound(sound, at); + for event in events { + match event { + MotionEvent::HurtSound(sound) => self.player_hurt_sound(sound, at), + MotionEvent::Fall(horizon_client::landing::FallEvent::Write { + position, + flags, + .. + }) => { + // Landing wrote the raw state: finish Level.setBlock's neighbour updates. + self.with_level(|b, level, ticks| { + b.notify_written(level, ticks, position, flags as i32) + }); + } + _ => {} + } } if let (Some(v), Some(g)) = (marked, host.hub.guest(conn)) { g.send(&C::SetEntityMotion(play::SetEntityMotion { diff --git a/tools/lan_e2e.py b/tools/lan_e2e.py index 3ece4b448..53100ad20 100755 --- a/tools/lan_e2e.py +++ b/tools/lan_e2e.py @@ -136,6 +136,8 @@ address. The script then checks, from both sides, what a guest's game used to ge server's game time after the guest's game stalls for a few seconds (#848). - growth: far from the host, the chunks around the guest tick (#890): water placed there flows and wheat on farmland grows (random ticks), however the host runs its world. +- farmland: the host and guest each trample planted farmland: the wheat breaks and drops its items, + and both clients see dirt/air (#1492). - ladder: the guest climbs down ten blocks of ladder and lands unhurt: the server resets its fall distance on a ladder every tick, as LivingEntity.handleOnClimbable does (#1255). - boats: the host (single player, on its server thread or not) and the guest each right-click a @@ -5496,5 +5498,72 @@ CHECKS += ['villagers'] CHECK_FNS.update(villagers=check_villagers) +def check_farmland(host, guest, out): + """FarmlandBlock.fallOn's base-block change breaks the unsupported crop (#1492): + the host and guest each land on mature wheat, get its drops, and both clients see dirt/air.""" + hx, hy, hz = (int(v // 1) for v in pos_of(host)) + y = max(hy + 12, 100) + starts = {g.name: pos_of(g) for g in (host, guest)} + seen = {} + host('command', command='gamerule random_tick_speed 0') + try: + for game, other, dz in ((host, guest, -3), (guest, host, 3)): + x, z = hx + 2, hz + dz + soil, crop, marker = (x, y, z), (x, y + 1, z), (x + 4, y + 1, z) + for g in (game, other): + g('command', command='gamemode creative') + host('command', command=f'fill {x - 4} {y} {z - 2} {x + 4} {y} {z + 2} minecraft:stone') + host('command', command=f'fill {x - 4} {y + 1} {z - 2} {x + 4} {y + 7} {z + 2} minecraft:air') + host('command', command=f'setblock {x} {y} {z} minecraft:farmland[moisture=7]') + host('command', command=f'setblock {x} {y + 1} {z} minecraft:wheat[age=7]') + other('command', command=f'tp @s {x + 3.5} {y + 1} {z + 0.5}') + game('command', command=f'tp @s {x + 2.5} {y + 1} {z + 0.5}') + game('command', command='clear @s') + game('command', command='gamemode survival') + game.wait(20) + before = {g.name: [g.raw('block', *p).get('block') for p in (soil, crop)] + for g in (host, guest)} + assert all(v == ['minecraft:farmland', 'minecraft:wheat'] for v in before.values()), \ + f'{game.name}: planted wheat missing before landing: {before}' + other.raw('look-at', x + 0.5, y + 1, z + 0.5) + other.shot(out, f'farmland-{game.name}-before') + # More than 1.5 blocks of fall distance guarantees the trampling random check. + game('command', command=f'tp @s {x + 0.5} {y + 6} {z + 0.5}') + game.wait(80) + after = {g.name: [g.raw('block', *p).get('block') for p in (soil, crop)] + for g in (host, guest)} + # Test the authoritative blocks too, rather than only each client's view. + game('command', command=f'execute if block {x} {y} {z} minecraft:dirt ' + f'if block {x} {y + 1} {z} minecraft:air run ' + f'setblock {marker[0]} {marker[1]} {marker[2]} minecraft:gold_block') + game.wait(10) + counts = {item: server_count(game, item) for item in ('wheat', 'wheat_seeds')} + client_counts = game('inventory')['counts'] + seen[game.name] = {'blocks': after, 'server': game.raw('block', *marker).get('block'), + 'drops': counts, + 'client_drops': {item: client_counts.get('minecraft:' + item, 0) + for item in counts}} + other.shot(out, f'farmland-{game.name}-after') + finally: + host('command', command='gamerule random_tick_speed 3') + host('command', command='kill @e[type=minecraft:item]') + for g in (host, guest): + x0, y0, z0 = starts[g.name] + g('command', command=f'tp @s {x0} {y0} {z0}') + g('command', command='gamemode survival') + for name, s in seen.items(): + assert all(v == ['minecraft:dirt', 'minecraft:air'] for v in s['blocks'].values()), \ + f'{name}: unsupported wheat after landing: {seen}' + assert s['server'] == 'minecraft:gold_block', f'{name}: server kept the unsupported wheat: {seen}' + assert s['drops']['wheat'] == 1 and 1 <= s['drops']['wheat_seeds'] <= 4, \ + f'{name}: mature wheat drops missing: {seen}' + assert s['client_drops'] == s['drops'], f'{name}: crop drops did not synchronize: {seen}' + return seen + + +CHECKS += ['farmland'] +CHECK_FNS.update(farmland=check_farmland) + + if __name__ == '__main__': main() From 3b586ff9038e97bb475973552edfc31b3a857c7e Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sun, 25 Oct 2026 05:48:29 +0100 Subject: [PATCH 2/2] Server players: one helper finishes a landing's block updates, turtle eggs too The server's player tick dropped FallEvent::Destroy, so an egg a guest broke by landing left its neighbours unupdated. Both paths now share the same helper. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game.rs | 32 +++++++++---------- crates/horizon-client/src/game/lan_actions.rs | 11 +------ 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index e25732bdd..a42efebdc 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -4046,6 +4046,20 @@ impl Game<'_> { self.capture_loaded_world(); Ok(()) } + /// Landing rules (farmland trampling, turtle eggs) wrote or removed the block + /// raw: finish `Level.setBlock`'s neighbour updates, so a crop on trampled + /// farmland breaks. The local player's and every server player's landings. + fn landing_block_updates(&mut self, event: &horizon_client::landing::FallEvent) { + use horizon_client::landing::FallEvent; + let (position, flags) = match *event { + FallEvent::Write { + position, flags, .. + } => (position, flags as i32), + FallEvent::Destroy { position, .. } => (position, level_flags::UPDATE_ALL), + _ => return, + }; + self.with_level(|b, level, ticks| b.notify_written(level, ticks, position, flags)); + } fn tick(&mut self) -> Result<()> { self.tick_debug_keys()?; self.tick_debug_charts(); @@ -4260,23 +4274,7 @@ 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(event) => self.landing_block_updates(&event), MotionEvent::Snowflake { position, velocity } => self.snowflake(position, velocity), MotionEvent::EnterBlock { state } => self.trigger_enter_block(state), MotionEvent::InsidePortal { pos } => self.player_inside_nether_portal(pos), diff --git a/crates/horizon-client/src/game/lan_actions.rs b/crates/horizon-client/src/game/lan_actions.rs index 21cb7dcf4..d0f16a0d6 100644 --- a/crates/horizon-client/src/game/lan_actions.rs +++ b/crates/horizon-client/src/game/lan_actions.rs @@ -2044,16 +2044,7 @@ impl Game<'_> { for event in events { match event { MotionEvent::HurtSound(sound) => self.player_hurt_sound(sound, at), - MotionEvent::Fall(horizon_client::landing::FallEvent::Write { - position, - flags, - .. - }) => { - // Landing wrote the raw state: finish Level.setBlock's neighbour updates. - self.with_level(|b, level, ticks| { - b.notify_written(level, ticks, position, flags as i32) - }); - } + MotionEvent::Fall(event) => self.landing_block_updates(&event), _ => {} } }