A guest's door, trapdoor, fence gate, lever and button use is predicted
Vanilla's MultiPlayerGameMode.useItemOn runs the use on the client's own level inside startPrediction, records each block it changes under the packet's sequence in BlockStatePredictionHandler, and keeps them until ClientboundBlockChangedAckPacket settles them (a use the server refused goes back). A Horizon guest only sent the use: its door opened one round trip later. The guest already ran the use on a dry copy of its level to know whether the click ends there; the blocks that use changes are now kept on its level as predictions under the use's sequence, as the break prediction does, when they are all hand-operated blocks: a wooden or copper door, trapdoor or fence gate, a lever or a button (an iron door has no hand use and changes nothing). The sound still comes from the server. lan_e2e `predict`: with the host process frozen, the oak door the guest clicks is already open on the guest's side (both halves), stays open on both sides once the server answers, and an iron door stays shut. Fixes #869 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+41
-3
@@ -52,6 +52,8 @@ address. The script then checks, from both sides, what a guest's game used to ge
|
||||
its crafting grid and gathers a stack with a double click; the server has each.
|
||||
- sleep: at night the guest lies down in its own bed (not the host); alone it stays night, it
|
||||
gets up with Escape, and once the host sleeps too the night ends and both wake.
|
||||
- predict: with the host frozen, the oak door the guest opens opens on the guest's screen at once (its
|
||||
prediction), and stays open once the server answers; an iron door stays shut (#869).
|
||||
- push: a cow standing in the guest pushes it just clear of the cow (the guest's own client
|
||||
pushes it, as in vanilla), not ever faster across the ground.
|
||||
- eat: holding right click with bread, the guest's own screen plays the eating (the item in use
|
||||
@@ -111,7 +113,7 @@ ROOT = Path(__file__).resolve().parents[1]
|
||||
GUEST_NAME = 'Guest'
|
||||
# The host plays single player on its server thread (--server-thread).
|
||||
SERVER_THREAD = False
|
||||
CHECKS = ['tab', 'self', 'armour', 'nametags', 'walls', 'chest', 'crafting', 'sign', 'damage', 'mobs', 'hazards', 'pvp', 'hurt', 'respawn', 'containers', 'feedback', 'titles', 'chat', 'commands', 'recipes', 'machines', 'brewing', 'trials', 'clicks', 'sleep', 'push', 'eat', 'eating', 'xp', 'objects', 'projectiles', 'light', 'time', 'swings', 'cracks', 'plates', 'effects', 'portals', 'distance', 'growth']
|
||||
CHECKS = ['tab', 'self', 'armour', 'nametags', 'walls', 'chest', 'crafting', 'sign', 'damage', 'mobs', 'hazards', 'pvp', 'hurt', 'respawn', 'containers', 'feedback', 'titles', 'chat', 'commands', 'recipes', 'machines', 'brewing', 'trials', 'clicks', 'sleep', 'predict', 'push', 'eat', 'eating', 'xp', 'objects', 'projectiles', 'light', 'time', 'swings', 'cracks', 'plates', 'effects', 'portals', 'distance', 'growth']
|
||||
|
||||
|
||||
class Game:
|
||||
@@ -1255,6 +1257,42 @@ def check_sleep(host, guest, out):
|
||||
assert lying['host'] and lying['guest'], f'a sleeping player is drawn standing: {detail}'
|
||||
assert not lying['after'], f'a player up again is still drawn lying: {detail}'
|
||||
return detail
|
||||
def check_predict(host, guest, out):
|
||||
# MultiPlayerGameMode.useItemOn under startPrediction (#869): the guest's door opens on its own screen
|
||||
# at once, with the host (the server) frozen, and the server's answer later agrees; an iron door
|
||||
# (no hand use) stays shut on both sides.
|
||||
guest('command', command='gamemode survival')
|
||||
guest('command', command='clear @s')
|
||||
x, y, z = (int(v // 1) for v in pos_of(guest))
|
||||
wood, iron = (x - 1, y, z + 2), (x + 1, y, z + 2)
|
||||
for (bx, by, bz), kind in ((wood, 'oak_door'), (iron, 'iron_door')):
|
||||
for half, dy in (('lower', 0), ('upper', 1)):
|
||||
host('command', command=f'setblock {bx} {by + dy} {bz} minecraft:{kind}[facing=north,hinge=right,half={half}]')
|
||||
guest.wait(20)
|
||||
state = lambda game, at: game.raw('block', *at)['state']
|
||||
seen = {}
|
||||
os.kill(host.pid, signal.SIGSTOP)
|
||||
try:
|
||||
guest.raw('interact', *wood)
|
||||
seen['guest_frozen'] = (state(guest, wood), state(guest, (wood[0], wood[1] + 1, wood[2])))
|
||||
guest.raw('interact', *iron)
|
||||
seen['guest_iron_frozen'] = state(guest, iron)
|
||||
finally:
|
||||
os.kill(host.pid, signal.SIGCONT)
|
||||
guest.wait(20)
|
||||
seen['guest_after'] = state(guest, wood)
|
||||
seen['host_after'] = state(host, wood)
|
||||
seen['iron_after'] = (state(guest, iron), state(host, iron))
|
||||
guest.shot(out, 'predict')
|
||||
for (bx, by, bz) in (wood, iron):
|
||||
host('command', command=f'fill {bx} {by} {bz} {bx} {by + 1} {bz} minecraft:air')
|
||||
assert all('open=true' in s for s in seen['guest_frozen']), f'the door waited for the server: {seen}'
|
||||
assert 'open=true' in seen['guest_after'] and 'open=true' in seen['host_after'], f'the door did not stay open: {seen}'
|
||||
assert 'open=false' in seen['guest_iron_frozen'], f'the guest opened an iron door by hand: {seen}'
|
||||
assert all('open=false' in s for s in seen['iron_after']), f'an iron door opened: {seen}'
|
||||
return seen
|
||||
|
||||
|
||||
def check_push(host, guest, out):
|
||||
guest('command', command='gamemode survival')
|
||||
x, y, z = (int(v // 1) + 0.5 for v in pos_of(guest))
|
||||
@@ -1712,7 +1750,7 @@ CHECK_FNS = {'tab': check_tab, 'self': check_self, 'armour': check_armour, 'name
|
||||
'xp': check_xp, 'objects': check_objects, 'projectiles': check_projectiles,
|
||||
'light': check_light, 'plates': check_plates,
|
||||
'swings': check_swings, 'cracks': check_cracks,
|
||||
'time': check_time, 'growth': check_growth}
|
||||
'time': check_time, 'growth': check_growth, 'predict': check_predict}
|
||||
|
||||
|
||||
def run(ctl, out, resources, checks):
|
||||
@@ -1721,7 +1759,7 @@ def run(ctl, out, resources, checks):
|
||||
host.d.env['HORIZON_SERVER_THREAD'] = '1'
|
||||
results = {}
|
||||
try:
|
||||
host('launch', wait=False, offscreen=sys.platform == 'darwin')
|
||||
host.pid = host('launch', wait=False, offscreen=sys.platform == 'darwin')['pid']
|
||||
# Guests' commands need the world's Allow Commands as well as the LAN's (#372): a creative
|
||||
# world has them; everyone plays in survival.
|
||||
host.raw('open', 'Lan', 5, 'creative')
|
||||
|
||||
Reference in New Issue
Block a user