Merge remote-tracking branch 'upstream/main' into fix/piston-entity-push
This commit is contained in:
+101
-12
@@ -341,8 +341,9 @@ class Game:
|
||||
def wait(self, ticks):
|
||||
self.d('wait', ticks=ticks)
|
||||
|
||||
def script(self, lines):
|
||||
"""Keep tick-sensitive input in one ctl process, through the normal control commands."""
|
||||
def script(self, lines, every=False):
|
||||
"""Keep tick-sensitive input in one ctl process, through the normal control commands. Returns the last
|
||||
reply, or with every=True all of them in order."""
|
||||
result = subprocess.run(self.d.base + ['script'], input='\n'.join(lines) + '\n',
|
||||
cwd=self.work, env=self.d.env, capture_output=True, text=True,
|
||||
timeout=600)
|
||||
@@ -350,7 +351,7 @@ class Game:
|
||||
ticks = [r['ticks'] for r in replies if 'ticks' in r]
|
||||
print(f'[{self.name}] script {lines} -> {replies[-1] if replies else result.stderr[:400]}; ticks={ticks}')
|
||||
assert result.returncode == 0 and replies and not any('error' in r for r in replies), result.stdout
|
||||
return replies[-1]
|
||||
return replies if every else replies[-1]
|
||||
|
||||
def until(self, observe, predicate, ticks=100):
|
||||
"""Wait for an observable answer, within the existing tick budget."""
|
||||
@@ -3132,13 +3133,15 @@ def check_fireworks(host, guest, out):
|
||||
game('command', command=f'tp @s {x + dx + 0.5} {y} {z + 0.5}')
|
||||
game.raw('look-at', x + 0.5, y + 1.5, z + 3.5)
|
||||
|
||||
def red(path):
|
||||
def reds(path):
|
||||
"""The red pixels' positions, above the hotbar."""
|
||||
rows, bpp = png_rows(path)
|
||||
# Exclude the hotbar and chat at the bottom of the view.
|
||||
return sum(row[i] > 80 and row[i] > 2 * row[i + 1] and row[i] > 2 * row[i + 2]
|
||||
for row in rows[:len(rows) * 3 // 4] for i in range(0, len(row), bpp))
|
||||
return {(y, i) for y, row in enumerate(rows[:len(rows) * 3 // 4]) for i in range(0, len(row), bpp)
|
||||
if row[i] > 80 and row[i] > 2 * row[i + 1] and row[i] > 2 * row[i + 2]}
|
||||
|
||||
baseline = {g.name: red(g.shot(out, 'fireworks-before')) for g in (host, guest)}
|
||||
# Red where the view had none: the setup's own red chat lines (a fill that changed nothing) are in the
|
||||
# baseline, and fade out before the later shots, which a plain count difference would take as missing sparks.
|
||||
baseline = {g.name: reds(g.shot(out, 'fireworks-before')) for g in (host, guest)}
|
||||
before = {g.name: made(g, 'flash') for g in (host, guest)}
|
||||
host('command', command='item replace entity @s weapon.mainhand with minecraft:firework_rocket'
|
||||
'[fireworks={flight_duration:0,explosions:[{shape:"large_ball",colors:[I;16711680],has_trail:true}]}]')
|
||||
@@ -3151,12 +3154,14 @@ def check_fireworks(host, guest, out):
|
||||
break
|
||||
flashes = {g.name: made(g, 'flash') - before[g.name] for g in (host, guest)}
|
||||
assert all(n == 1 for n in flashes.values()), f'configured burst missing or duplicated: {flashes}'
|
||||
# Capture both views before decoding PNGs: decoding must not consume the sparks' lifetime.
|
||||
# Capture both views before decoding PNGs: decoding must not consume the sparks' lifetime (48-59 ticks). A
|
||||
# screenshot takes ~0.6 s where the frame is drawn on the CPU (lavapipe), so the later shots come 4 ticks after
|
||||
# the burst's, not more: by then the tracked rocket is gone.
|
||||
burst_shots = {g.name: g.shot(out, 'fireworks-burst') for g in (host, guest)}
|
||||
host.wait(16)
|
||||
host.wait(4)
|
||||
trail_shots = {g.name: g.shot(out, 'fireworks-trail-fade') for g in (host, guest)}
|
||||
burst = {name: red(path) - baseline[name] for name, path in burst_shots.items()}
|
||||
trails = {name: red(path) - baseline[name] for name, path in trail_shots.items()}
|
||||
burst = {name: len(reds(path) - baseline[name]) for name, path in burst_shots.items()}
|
||||
trails = {name: len(reds(path) - baseline[name]) for name, path in trail_shots.items()}
|
||||
rockets = {g.name: g('status')['rockets'] for g in (host, guest)}
|
||||
assert not any(rockets.values()), f'exploded rocket remains: {rockets}'
|
||||
assert all(n > 20 for n in burst.values()), f'no red burst: {burst}'
|
||||
@@ -7311,6 +7316,90 @@ CHECKS += ['guardian-beams']
|
||||
CHECK_FNS['guardian-beams'] = check_guardian_beams
|
||||
|
||||
|
||||
def check_fangs(host, guest, out):
|
||||
"""EvokerFangs: authoritative spawn, event 4, client animation and server removal (#1482)."""
|
||||
x, y, z = (int(v // 1) for v in pos_of(host))
|
||||
tag = 'lan_evoker_fangs'
|
||||
selector = f'@e[type=minecraft:evoker,tag={tag},limit=1]'
|
||||
paths = {g.name: {} for g in (host, guest)}
|
||||
warmup = dict.fromkeys(paths, False)
|
||||
drawn = dict.fromkeys(paths, False)
|
||||
stopped = False
|
||||
photographed = False
|
||||
|
||||
def fangs(status):
|
||||
return [p for p in status['projectiles'] if p['kind'] == 'minecraft:evoker_fangs']
|
||||
|
||||
try:
|
||||
host('command', command='difficulty normal')
|
||||
host('command', command='gamemode creative')
|
||||
guest('command', command='gamemode survival')
|
||||
guest('command', command='effect give @s minecraft:resistance 120 4 true')
|
||||
host('command', command=f'fill {x - 10} {y - 1} {z - 10} {x + 10} {y - 1} {z + 18} minecraft:stone')
|
||||
host('command', command=f'fill {x - 10} {y} {z - 10} {x + 10} {y + 8} {z + 18} minecraft:air')
|
||||
host('command', command=f'tp @s {x + 4.5} {y} {z - 2.5}')
|
||||
guest('command', command=f'tp @s {x + 0.5} {y} {z + 0.5}')
|
||||
guest.wait(10)
|
||||
host('command', command=f'summon minecraft:evoker {x + 0.5} {y} {z + 9.5} '
|
||||
f'{{PersistenceRequired:1b,Tags:["{tag}"]}}')
|
||||
for game in (host, guest):
|
||||
game.raw('look-at', x + 0.5, y + 0.5, z + 5.5)
|
||||
for _ in range(200):
|
||||
guest.wait(2)
|
||||
statuses = {g.name: g('status') for g in (host, guest)}
|
||||
for name, status in statuses.items():
|
||||
live = fangs(status)
|
||||
ids = [f['id'] for f in live]
|
||||
assert all(ids) and len(ids) == len(set(ids)), f'{name}: invalid fang ids {ids}'
|
||||
warmup[name] |= any(not f['started'] for f in live)
|
||||
drawn[name] |= status['fangs_vertices'] > 0
|
||||
for f in live:
|
||||
paths[name].setdefault(f['id'], []).append(f)
|
||||
if paths['host'] and not stopped:
|
||||
host('command', command=f'data merge entity {selector} {{NoAI:1b}}')
|
||||
stopped = True
|
||||
if (all(drawn.values()) and not photographed
|
||||
and any(f['started'] and 8 <= f['life'] <= 16
|
||||
for f in fangs(statuses['guest']))):
|
||||
host('command', command='tick freeze')
|
||||
try:
|
||||
for game in (host, guest):
|
||||
game.raw('key', 'f1', 'tap')
|
||||
try:
|
||||
game.shot(out, 'evoker-fangs')
|
||||
finally:
|
||||
game.raw('key', 'f1', 'tap')
|
||||
finally:
|
||||
host('command', command='tick unfreeze')
|
||||
photographed = True
|
||||
if stopped and not any(fangs(s) for s in statuses.values()):
|
||||
break
|
||||
lab.write_json(out / 'evoker-fangs.json', {'paths': paths, 'warmup': warmup, 'drawn': drawn})
|
||||
assert all(warmup.values()), f'fang warmup not received: {warmup}'
|
||||
assert all(drawn.values()), f'fang renderer produced no geometry: {drawn}'
|
||||
assert paths['host'].keys() == paths['guest'].keys(), 'clients received different fang ids'
|
||||
for id, samples in paths['host'].items():
|
||||
other = paths['guest'][id]
|
||||
assert all(f['position'] == samples[0]['position'] for f in samples + other), \
|
||||
f'fang {id} is not at its authoritative position'
|
||||
for name, frames in (('host', samples), ('guest', other)):
|
||||
life = {f['life'] for f in frames if f['started']}
|
||||
assert len(life) > 1, f'{name}: fang {id} did not animate: {frames}'
|
||||
assert not any(fangs(g('status')) for g in (host, guest)), 'fangs survived server removal'
|
||||
finally:
|
||||
host('command', command='tick unfreeze')
|
||||
host('command', command=f'kill @e[tag={tag}]')
|
||||
# The evoker can summon vexes before fangs; killing it leaves those summons alive.
|
||||
host('command', command=f'kill @e[type=minecraft:vex,x={x},y={y},z={z},distance=..32]')
|
||||
guest('command', command='effect clear @s')
|
||||
face_each_other(host, guest)
|
||||
return {'fangs': len(paths['host']), 'warmup': warmup, 'drawn': drawn, 'removed': True}
|
||||
|
||||
|
||||
CHECKS += ['fangs']
|
||||
CHECK_FNS.update(fangs=check_fangs)
|
||||
|
||||
|
||||
def check_sonic(host, guest, out):
|
||||
"""A real warden's ray reaches connected clients once, with normal damage.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user