Splitscreen: a player's pack reload no longer deletes P1's overlay

Fixes #10179.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
martipopsandClaude Opus 5.5 committed 2026-11-05 14:10:42 -05:00
1 parent f2f95dad8a
commit d8781cb9df
2 files changed
+38 -3

No files matched your search

@@ -454,12 +454,14 @@ impl Split<'_> {
});
let mut settings = settings;
settings.extras.agent_control &= options.control.is_some();
let gui = UiResources::load(&options.resources, &options.resources)?;
// `options.resources` is P1's overlay when a pack is on: never the vanilla root, as a
// reload would rebuild that overlay out of itself.
let vanilla_root = host.vanilla_root();
let gui = UiResources::load(&options.resources, &vanilla_root)?;
// P1's output, heard from this player's camera too (`Audio::share`).
let audio = host.audio.share(seat as u8);
let window = host.window.clone().ok_or("no window")?;
let pack = host.pack.clone();
let resources = host.options.resources.clone();
let mut guest = boxed(|| {
start_game(
res,
@@ -468,7 +470,7 @@ impl Split<'_> {
options,
None,
audio,
resources,
vanilla_root,
Instant::now(),
None,
Some(settings),
+33
View File
@@ -38,6 +38,7 @@ import subprocess
import sys
import tempfile
import time
import zipfile
from pathlib import Path
try:
@@ -1018,6 +1019,37 @@ def scenario_packs():
files.shutdown()
shutil.rmtree(folder, ignore_errors=True)
def scenario_pack_overlay():
print("pack_overlay: a player's pack reload leaves P1's selected pack and vanilla's files in place")
def seed(home):
(home / 'resourcepacks').mkdir()
meta = {'pack': {'pack_format': 9999, 'supported_formats': {'min_inclusive': 6, 'max_inclusive': 9999},
'description': 'pack_overlay'}}
with zipfile.ZipFile(home / 'resourcepacks/overlay.zip', 'w') as z:
z.writestr('pack.mcmeta', json.dumps(meta))
(home / 'options.txt').write_text('resourcePacks:["vanilla","file/overlay.zip"]\n')
(home / 'shaderpacks').mkdir()
with zipfile.ZipFile(home / 'shaderpacks/shader.zip', 'w') as z:
z.writestr('shaders/final.fsh', 'void main() {}\n')
g = Game(2, seed=seed, args=('--offscreen',))
try:
log = g.home / 'logs/latest.log'
stone = 'assets/minecraft/textures/block/stone.png'
overlays = [d for d in (g.home / '.horizon-cache/resourcepacks').iterdir() if d.is_dir()]
check('one overlay for the selection', len(overlays), 1)
check("vanilla's stone in it before", (overlays[0] / stone).exists(), True)
# The first shader pack of a session turns material maps on, which reloads the packs.
g.ctl(2, 'options', 'shader-packs')
g.press(2, 'shader.zip')
g.wait(lambda: 'shader pack shader.zip' in log.read_text(errors='replace'), "P2's shader pack", seconds=60)
check("vanilla's stone in it after", (overlays[0] / stone).exists(), True)
check('the reload succeeded', 'resource reload failed' in log.read_text(errors='replace'), False)
finally:
g.quit()
def scenario_server():
print('server: P1 on a dedicated server; the others join it, a kicked one drops out, all leave with P1')
with dedicated() as (server, port):
@@ -1383,6 +1415,7 @@ SCENARIOS = {
'pausemenu': scenario_pausemenu,
'server': scenario_server,
'packs': scenario_packs,
'pack_overlay': scenario_pack_overlay,
'dedicated_profiles': scenario_dedicated_profiles,
'integrated_profiles': scenario_integrated_profiles,
'launcher': scenario_launcher,