From 55891f9c95d083afd6247f97bd7ea9fd3b6b5864 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sat, 17 Oct 2026 19:34:46 +0200 Subject: [PATCH] Wait for the server's block in the agent's place, try hidden spots On a client of a server (single player's server thread, a LAN guest) the placed block comes with the server's answer: `place` waits up to a second for it before reporting no change. agent_control_e2e tries the next free spot when the tree's trunk above the broken log hides a spot's faces. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit 9821bb7ef54112200c720c2ca91f10187b4ea693) --- crates/horizon-client/src/game/agent.rs | 12 +++++++++++- tools/agent_control_e2e.py | 23 +++++++++++++++-------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/crates/horizon-client/src/game/agent.rs b/crates/horizon-client/src/game/agent.rs index 5d7d294dd..9a5cd6a58 100644 --- a/crates/horizon-client/src/game/agent.rs +++ b/crates/horizon-client/src/game/agent.rs @@ -1840,11 +1840,21 @@ impl Game<'_> { if self.ticks < *report_tick && !timed_out { return None; } - let after = pos.map(|p| self.block_json(p)); let changed = match (*pos, *before) { (Some(p), Some(b)) => self.world.block(p[0], p[1], p[2]) != b, _ => false, }; + // A client of a server (single player's server thread, a LAN + // guest) sees the block once the server's answer comes. + if *place + && !changed + && self.remote.is_some() + && self.ticks < *report_tick + 20 + && !timed_out + { + return None; + } + let after = pos.map(|p| self.block_json(p)); let used = delta(inventory, &self.inventory_counts()); let mut v = json!({ "ok": !*place || changed, diff --git a/tools/agent_control_e2e.py b/tools/agent_control_e2e.py index 4edc7ae55..a3690f9d7 100644 --- a/tools/agent_control_e2e.py +++ b/tools/agent_control_e2e.py @@ -253,20 +253,27 @@ def scenario(d, out): # 5. Place a plank beside the player and read it back. p = d('state')['player']['block_pos'] - target = None + hotbar = d('inventory')['hotbar'] + if not any(s.get('item') == planks_id for s in hotbar): + raise Failed(f'{planks_id} did not land in the hotbar: {hotbar}') + target = placed = None for dx, dz in [(2, 0), (-2, 0), (0, 2), (0, -2), (2, 1), (1, 2), (-2, -1), (-1, -2)]: at = (p[0] + dx, p[1], p[2] + dz) here = d('block', x=at[0], y=at[1], z=at[2])['block'] below = d('block', x=at[0], y=at[1] - 1, z=at[2])['block'] - if here in ('minecraft:air', 'minecraft:short_grass') and below not in ('minecraft:air', 'minecraft:water'): - target = at - break + if here not in ('minecraft:air', 'minecraft:short_grass') or below in ('minecraft:air', 'minecraft:water'): + continue + # The tree's trunk above the broken log can hide a spot's faces: try the next one. + try: + placed = d('place', x=at[0], y=at[1], z=at[2], item=planks_id) + except Failed as e: + if 'no visible face' in str(e): + continue + raise + target = at + break if target is None: raise Failed(f'no free spot beside {p} to place a block') - hotbar = d('inventory')['hotbar'] - if not any(s.get('item') == planks_id for s in hotbar): - raise Failed(f'{planks_id} did not land in the hotbar: {hotbar}') - placed = d('place', x=target[0], y=target[1], z=target[2], item=planks_id) assert placed['changed'], placed back = d('block', x=target[0], y=target[1], z=target[2]) assert back['block'] == planks_id, back