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 <noreply@anthropic.com>
(cherry picked from commit 9821bb7ef54112200c720c2ca91f10187b4ea693)
This commit is contained in:
Ludovic Marie
2026-10-17 19:34:46 +02:00
parent 2f883b5cdb
commit 55891f9c95
2 changed files with 26 additions and 9 deletions
+11 -1
View File
@@ -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,
+15 -8
View File
@@ -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