Merge remote-tracking branch 'origin/main' into fix/st-fishing

# Conflicts:
#	tools/lan_e2e.py
This commit is contained in:
Ludovic Marie
2026-10-24 05:06:43 +02:00
10 changed files with 235 additions and 411 deletions
+68
View File
@@ -4959,5 +4959,73 @@ CHECKS += ['fishing']
CHECK_FNS.update(fishing=check_fishing)
def check_digging(host, guest, out):
"""The server breaks a block a player digs only once that player's client is done
(ServerPlayerGameMode: STOP_DESTROY_BLOCK, or the delayed destroy), never on its own count, so
the player's client always breaks it first, with its particles and sound. The guest holds
attack across a wall of six oak logs with a copper axe and hears each one break; then it digs
stone with a wooden pickaxe and its game stalls for a second halfway: the stone is still there
on both sides when it resumes, and the guest's own crack finishes it."""
gx, gy, gz = (int(v // 1) for v in pos_of(guest))
x, y, z = gx + 3, gy, gz + 4
heard = lambda sound: guest('status')['heard'].get(sound, 0)
at = lambda b: (f'{b[0] + 0.02:.2f}', f'{b[1] + 0.5:.2f}', f'{b[2] + 0.5:.2f}')
guest('command', command='gamemode survival')
guest('command', command='item replace entity @s weapon.mainhand with minecraft:copper_axe')
host('command', command=f'fill {x - 2} {y - 1} {z - 2} {x + 4} {y + 3} {z + 2} minecraft:air')
host('command', command=f'fill {x - 2} {y - 1} {z - 2} {x + 4} {y - 1} {z + 2} minecraft:stone')
host('command', command=f'fill {x + 2} {y} {z - 1} {x + 2} {y + 1} {z + 1} minecraft:oak_log')
guest('command', command=f'tp @s {x + 0.5} {y} {z + 0.5}')
guest.wait(30)
logs = [(x + 2, y + dy, z + dz) for dz in (-1, 0, 1) for dy in (0, 1)]
before = heard('minecraft:block.wood.break')
guest.raw('look-at', *at(logs[0]))
guest.raw('mouse', 'left', 'down')
left = list(logs)
deadline = time.time() + 20
while left and time.time() < deadline:
if guest.raw('block', *left[0]).get('block') != 'minecraft:oak_log':
left.pop(0)
if left:
guest.raw('look-at', *at(left[0]))
guest.raw('mouse', 'left', 'up')
guest.wait(10)
seen = {'logs_left': left, 'log_breaks_heard': heard('minecraft:block.wood.break') - before}
# Stone with a wooden pickaxe: 23 ticks. The guest stalls for a second after about 8.
stone = (x + 2, y, z)
guest('command', command='item replace entity @s weapon.mainhand with minecraft:wooden_pickaxe')
host('command', command=f'setblock {stone[0]} {stone[1]} {stone[2]} minecraft:stone')
guest.wait(10)
before = heard('minecraft:block.stone.break')
guest.raw('look-at', *at(stone))
guest.raw('mouse', 'left', 'down')
time.sleep(0.4)
os.kill(guest.pid, signal.SIGSTOP)
try:
time.sleep(1.0)
finally:
os.kill(guest.pid, signal.SIGCONT)
resumed = {'guest': guest.raw('block', *stone).get('block'), 'server': host.raw('block', *stone).get('block'),
'mining': guest('state').get('mining')}
# Let go once it breaks: past it the crosshair reaches the floor.
deadline = time.time() + 5
while guest.raw('block', *stone).get('block') == 'minecraft:stone' and time.time() < deadline:
pass
guest.raw('mouse', 'left', 'up')
guest.wait(10)
seen.update(resumed=resumed, stone_after=host.raw('block', *stone).get('block'),
stone_breaks_heard=heard('minecraft:block.stone.break') - before)
guest.shot(out, 'digging')
assert not left and seen['log_breaks_heard'] == 6, f'the server broke logs before the guest did: {seen}'
assert resumed['guest'] == resumed['server'] == 'minecraft:stone', f'the server broke the stone while the guest stalled: {seen}'
assert seen['stone_after'] == 'minecraft:air' and seen['stone_breaks_heard'] == 1, f'the guest did not break the stone: {seen}'
return seen
CHECKS += ['digging']
CHECK_FNS.update(digging=check_digging)
if __name__ == '__main__':
main()