9c7909f770
Co-Authored-By: OpenAI Codex GPT-6.1 <noreply@openai.com>
63 lines
2.8 KiB
Python
63 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
"""A connected client advances ghast fireballs between tracker packets.
|
|
|
|
AbstractHurtingProjectile.tick/applyInertia run on clients as well as servers.
|
|
Like lan_e2e's falling-entity check, sample motion more often than the tracker
|
|
interval; an interpolation-only client stalls for most of that interval.
|
|
"""
|
|
import json
|
|
import math
|
|
import subprocess
|
|
|
|
import lab
|
|
import lan_e2e as lan
|
|
|
|
|
|
def check_motion(host, guest, out):
|
|
x, y, z = (math.floor(v) for v in lan.pos_of(guest))
|
|
for game in (host, guest):
|
|
game('command', command='gamemode creative')
|
|
tag = 'remote_fireball_parity'
|
|
host('command', command=f'fill {x + 2} {y + 18} {z - 1} {x + 48} {y + 23} {z + 1} minecraft:air')
|
|
host('command', command=f'summon minecraft:fireball {x + 3.5} {y + 20} {z + 0.5} '
|
|
f'{{Tags:["{tag}"],Motion:[0.1d,0.0d,0.0d]}}')
|
|
samples = []
|
|
try:
|
|
for _ in range(8):
|
|
balls = [p for p in guest('status')['projectiles'] if p['kind'] == 'LargeFireball']
|
|
samples.append(balls[0]['position'][0] if balls else None)
|
|
guest.wait(2)
|
|
finally:
|
|
host('command', command=f'kill @e[tag={tag}]')
|
|
seen = [p for p in samples if p is not None]
|
|
assert len(seen) >= 6, f'fireball visible in only {len(seen)} samples: {samples}'
|
|
moves = sum(b != a for a, b in zip(seen, seen[1:]))
|
|
assert moves >= len(seen) - 2, f'fireball stalled between tracker updates: {samples}'
|
|
return {'positions': samples}
|
|
|
|
|
|
def main():
|
|
subprocess.run(['cargo', 'build', '--locked', '--profile', 'fast', '-p', 'horizon-client',
|
|
'--bin', 'horizon-client', '--bin', 'horizon-ctl'], cwd=lab.ROOT, check=True)
|
|
metadata = json.loads(subprocess.check_output(
|
|
['cargo', 'metadata', '--format-version', '1', '--no-deps'], cwd=lab.ROOT, text=True))
|
|
ctl = lab.ROOT / metadata['target_directory'] / 'fast' / 'horizon-ctl'
|
|
lan.CHECK_FNS['remote-fireball'] = check_motion
|
|
# Use the runner's current display (xvfb on Linux), with fresh isolated homes.
|
|
lan.game_env = lambda _screen, home: lab.game_env(
|
|
HORIZON_HOME=home, HORIZON_TELEMETRY_URL='off')
|
|
reports = {}
|
|
for threaded in (True, False):
|
|
lan.SERVER_THREAD = threaded
|
|
mode = 'server-thread' if threaded else 'in-frame'
|
|
out = lab.LOCAL / 'remote-fireball-parity' / mode
|
|
out.mkdir(parents=True, exist_ok=True)
|
|
# lan.Game launches each client with lab.game_env and private scratch homes.
|
|
reports[mode] = lan.run(ctl, out, lab.RESOURCES.resolve(), ['remote-fireball'])
|
|
lab.write_json(lab.LOCAL / 'remote-fireball-parity' / 'report.json', reports)
|
|
assert all(r['pass'] for mode in reports.values() for r in mode.values()), reports
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|