Merge pull request #1099 from ludovic111/fix/lan-e2e-xp-host-back

🤖 Agent: merged. Test-only fix to tools/lan_e2e.py (root cause in the body); verify and CI parity pass.
This commit is contained in:
Ludovic Marie
2026-10-21 21:02:45 +02:00
committed by GitHub
+24 -16
View File
@@ -1389,23 +1389,31 @@ def check_xp(host, guest, out):
g('command', command='xp set @s 0 points') g('command', command='xp set @s 0 points')
# Out of the orbs' way wherever an earlier check left the host (ExperienceOrb follows the # Out of the orbs' way wherever an earlier check left the host (ExperienceOrb follows the
# nearest player who isn't a spectator). # nearest player who isn't a spectator).
hx, hy, hz = pos_of(host)
host('command', command='gamemode spectator') host('command', command='gamemode spectator')
guest.wait(10) try:
# `xp set` leaves Player.totalExperience (the score): experience from earlier checks stays in it. guest.wait(10)
total = guest('state')['player']['xp']['total'] # `xp set` leaves Player.totalExperience (the score): experience from earlier checks stays in it.
host_total = host('state')['player']['xp']['total'] total = guest('state')['player']['xp']['total']
x, y, z = pos_of(guest) host_total = host('state')['player']['xp']['total']
# Three orbs of 7 points 4 blocks east of the guest (out of reach, within the 8 blocks orbs x, y, z = pos_of(guest)
# follow from): they fly to the guest. # Three orbs of 7 points 4 blocks east of the guest (out of reach, within the 8 blocks orbs
for _ in range(3): # follow from): they fly to the guest.
guest('command', command=f'summon minecraft:experience_orb {x + 4:.2f} {y + 0.5:.2f} {z:.2f} {{Value:7s}}') for _ in range(3):
guest.wait(2) guest('command', command=f'summon minecraft:experience_orb {x + 4:.2f} {y + 0.5:.2f} {z:.2f} {{Value:7s}}')
seen = remote(guest).get('entities', {}).get('minecraft:experience_orb', 0) guest.wait(2)
guest.shot(out, 'xp-orbs') seen = remote(guest).get('entities', {}).get('minecraft:experience_orb', 0)
guest.wait(60) guest.shot(out, 'xp-orbs')
xp = guest('state')['player']['xp'] guest.wait(60)
host_xp = host('state')['player']['xp'] xp = guest('state')['player']['xp']
left = remote(guest).get('entities', {}).get('minecraft:experience_orb', 0) host_xp = host('state')['player']['xp']
left = remote(guest).get('entities', {}).get('minecraft:experience_orb', 0)
finally:
host('command', command='gamemode survival')
# Back where it stood: a spectator sinks (Player.travel keeps 0.6 of its fall speed each tick,
# about 0.2 blocks from standing), and a later check that makes it survival again would land
# it inside the floor, with the guest teleported beside it (swings).
host('command', command=f'tp @s {hx:.2f} {hy:.2f} {hz:.2f}')
detail = {'seen': seen, 'guest': xp, 'host': host_xp, 'left': left} detail = {'seen': seen, 'guest': xp, 'host': host_xp, 'left': left}
# ExperienceOrb.scanForMerges: orbs of one value side by side can merge into one. # ExperienceOrb.scanForMerges: orbs of one value side by side can merge into one.
assert 1 <= seen <= 3, f'the guest saw {seen} orbs: {detail}' assert 1 <= seen <= 3, f'the guest saw {seen} orbs: {detail}'