lan_e2e and agent_control_e2e on the server thread
From b9f3821f (fix/server-thread-default): the host window draws what it was sent on the server thread, and agent_control_e2e waits two ticks where the server answers a click. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -244,10 +244,12 @@ def scenario(d, out):
|
||||
d('click_slot', slot=log_slot) # pick up the logs
|
||||
d('click_slot', slot=100, right=True) # put one in the crafting grid
|
||||
d('click_slot', slot=log_slot) # put the rest back
|
||||
d('wait', ticks=2) # the server crafts the result (single player's server thread)
|
||||
result = next(s for s in d('screen')['slots'] if s['slot'] == 200)
|
||||
assert result.get('item') == planks_id and result['count'] == 4, result
|
||||
d('click_slot', slot=200, shift=True) # craft into the inventory
|
||||
d('close')
|
||||
d('wait', ticks=2)
|
||||
inventory = d('inventory')
|
||||
assert inventory['counts'].get(planks_id, 0) >= 4, inventory
|
||||
|
||||
@@ -329,6 +331,7 @@ def ui_scenario(d, out):
|
||||
|
||||
# 3. The inventory's slots are widgets too, with their stacks.
|
||||
d('give', item='oak_log', count=2)
|
||||
d('wait', ticks=2) # single player's server thread gives them
|
||||
d('open_inventory')
|
||||
tree = widgets(d)
|
||||
log = next(w for w in tree.values() if w['kind'] == 'slot' and (w.get('stack') or {}).get('item') == 'minecraft:oak_log')
|
||||
@@ -336,6 +339,7 @@ def ui_scenario(d, out):
|
||||
d('click', id=log['id'])
|
||||
d('click', id='slot-100', right=True)
|
||||
d('click', id=log['id'])
|
||||
d('wait', ticks=2)
|
||||
assert widgets(d)['slot-200']['stack']['item'] == 'minecraft:oak_planks'
|
||||
d('close')
|
||||
shot = d('screenshot', path=str(out / f'{d.name}-ui.png'))
|
||||
|
||||
+20
-6
@@ -168,6 +168,11 @@ def remote(guest):
|
||||
return guest('status')['server']
|
||||
|
||||
|
||||
def dead(guest):
|
||||
"""Whether the guest is dead: its death screen (the last health it was sent can stay above 0)."""
|
||||
return guest('state').get('screen') == 'dead' or remote(guest)['health'] <= 0
|
||||
|
||||
|
||||
def back_to_game(game):
|
||||
"""Close whatever screen a failed check left open, without opening the pause menu."""
|
||||
try:
|
||||
@@ -227,9 +232,15 @@ def check_armour(host, guest, out):
|
||||
face_each_other(host, guest)
|
||||
host.shot(out, 'armour')
|
||||
guest.shot(out, 'armour')
|
||||
seen = lan_guest(host).get('model_armor')
|
||||
assert seen == [None, 'minecraft:diamond_chestplate', 'minecraft:diamond_leggings', None], \
|
||||
f'the host draws the guest in {seen}'
|
||||
if SERVER_THREAD:
|
||||
# The host's window is a client of its server thread: what it draws is what it was sent.
|
||||
seen = [e for e in remote(host).get('player_equipment', [])]
|
||||
assert all(any(item in json.dumps(e) for e in seen) for item in
|
||||
('diamond_chestplate', 'diamond_leggings')), f'the host draws the guest in {seen}'
|
||||
else:
|
||||
seen = lan_guest(host).get('model_armor')
|
||||
assert seen == [None, 'minecraft:diamond_chestplate', 'minecraft:diamond_leggings', None], \
|
||||
f'the host draws the guest in {seen}'
|
||||
host_gear = [e for e in remote(guest).get('player_equipment', [])]
|
||||
assert any('golden_chestplate' in json.dumps(e) for e in host_gear), f'the guest sees the host in {host_gear}'
|
||||
return 'each in their own'
|
||||
@@ -559,7 +570,7 @@ def check_hazards(host, guest, out):
|
||||
x, y, z = hx + 3, hy, hz
|
||||
for name, fill, ticks in (('lava', 'minecraft:lava', 60), ('wall', 'minecraft:stone', 60),
|
||||
('drowning', 'minecraft:water', 500), ('void', None, 60)):
|
||||
if remote(guest)['health'] <= 0:
|
||||
if dead(guest):
|
||||
guest.raw('respawn')
|
||||
guest.wait(40)
|
||||
# A stone box around the guest holds the lava and the water in.
|
||||
@@ -582,7 +593,7 @@ def check_hazards(host, guest, out):
|
||||
host('command', command=f'fill {x - 1} {y - 1} {z - 1} {x + 1} {y + 2} {z + 1} minecraft:air')
|
||||
host('command', command=f'fill {x - 1} {y - 1} {z - 1} {x + 1} {y - 1} {z + 1} minecraft:stone')
|
||||
guest.wait(20)
|
||||
if remote(guest)['health'] <= 0:
|
||||
if dead(guest):
|
||||
guest.raw('respawn')
|
||||
guest.wait(40)
|
||||
# [food, saturation, exhaustion]: 8 s of sprint-jumping is about 2 of exhaustion; every 4
|
||||
@@ -595,6 +606,9 @@ def check_hazards(host, guest, out):
|
||||
|
||||
|
||||
def check_pvp(host, guest, out):
|
||||
if dead(guest):
|
||||
guest.raw('respawn')
|
||||
guest.wait(40)
|
||||
for g in (host, guest):
|
||||
g('command', command='gamemode survival')
|
||||
g('command', command='item replace entity @s weapon.mainhand with minecraft:iron_sword')
|
||||
@@ -1104,7 +1118,7 @@ def check_walls(host, guest, out):
|
||||
for g in (host, guest):
|
||||
back_to_game(g)
|
||||
# The trial spawner's zombies may have killed the guest.
|
||||
if guest('state').get('screen') == 'dead' or remote(guest)['health'] <= 0:
|
||||
if dead(guest):
|
||||
guest.raw('respawn')
|
||||
guest.wait(40)
|
||||
face_each_other(host, guest)
|
||||
|
||||
Reference in New Issue
Block a user