- tools/quests.py writes pack/config/ftbquests/quests/ in FTB Quests 2101's format (data.snbt, chapters/*.snbt, texts in lang/en_us.snbt) with ids derived from the YAML names, so progress survives regeneration. Flexible progression, no lock icons, no rewards (Adrian, 2026-11-03). tools/build.py runs it. - docs/quests.yaml: 18 chapters, 74 quests. Getting Started; one chapter per zone and the End from a zone template (reach it, catch three of its Pokemon, mine its ores, beat its guardian) plus chapter extras (Mire Waders, Eyes of Ender, Eternatus); Pokemon Machines; Base and Jobs. - Node positions: --pull reads them from an FTB Quests folder into the layout block (only moved nodes); tools/prism_instance.py pulls from the instance before each sync and rebuilds if something moved. - The pack's own events as hidden advancements (cobblesurvival:events/...), granted by QuestEvents: zone reached, guardian beaten, machine filled, End boss beaten. - Self-tests quest_book_loads and quest_events_mark_zones; the guardian and furnace tests check their events. Self-tests and island check pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
133 lines
4.7 KiB
Python
133 lines
4.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Build the companion mod and export the pack.
|
|
|
|
Outputs, all under build/:
|
|
stage/full/ every mod plus the companion jar; the Prism
|
|
instance and the server smoke test install this
|
|
<slug>-<ver>.mrpack Modrinth pack
|
|
<slug>-<ver>-curseforge.zip CurseForge pack
|
|
|
|
Each platform export only lists mods that platform hosts. A mod hosted on just
|
|
one platform is left out of the other export and reported; it is never copied
|
|
into overrides/, because the pack must not bundle third-party jars. The
|
|
companion mod is our own work, so it is the one jar allowed in overrides/.
|
|
|
|
Usage: tools/build.py [--skip-mod]
|
|
"""
|
|
import argparse
|
|
import os
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
import tomllib
|
|
import zipfile
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
PACK = ROOT / "pack"
|
|
BUILD = ROOT / "build"
|
|
MODRINTH_HOSTS = ("https://cdn.modrinth.com/", "https://github.com/",
|
|
"https://raw.githubusercontent.com/", "https://gitlab.com/")
|
|
|
|
|
|
def run(cmd, cwd):
|
|
print(f"$ {' '.join(map(str, cmd))} (in {cwd.relative_to(ROOT) if cwd.is_relative_to(ROOT) else cwd})")
|
|
subprocess.run(cmd, cwd=cwd, check=True)
|
|
|
|
|
|
def packwiz(*args, cwd):
|
|
run([shutil.which("packwiz") or "packwiz", *args, "-y"], cwd)
|
|
|
|
|
|
def java_home():
|
|
"""Gradle 8.14 cannot run on Java 25, so prefer an explicit Java 21."""
|
|
for candidate in (os.environ.get("JAVA21_HOME"), os.environ.get("JAVA_HOME"),
|
|
Path.home() / ".var/app/org.prismlauncher.PrismLauncher/data/PrismLauncher/java/java-runtime-delta"):
|
|
if candidate and (Path(candidate) / "bin" / "java").exists():
|
|
return str(candidate)
|
|
return None
|
|
|
|
|
|
def build_mod():
|
|
env = dict(os.environ)
|
|
if home := java_home():
|
|
env["JAVA_HOME"] = home
|
|
subprocess.run(["./gradlew", "build", "--console=plain"], cwd=ROOT / "mod", env=env, check=True)
|
|
|
|
|
|
def companion_jar():
|
|
props = dict(line.split("=", 1) for line in (ROOT / "mod/gradle.properties").read_text().splitlines()
|
|
if "=" in line and not line.startswith("#"))
|
|
jar = ROOT / "mod/build/libs" / f"{props['mod_id']}-{props['mod_version']}.jar"
|
|
if not jar.exists():
|
|
sys.exit(f"companion jar not found: {jar} (run without --skip-mod)")
|
|
return jar
|
|
|
|
|
|
def platforms_of(meta):
|
|
hosts = set()
|
|
if "curseforge" in meta.get("update", {}):
|
|
hosts.add("curseforge")
|
|
if meta.get("download", {}).get("url", "").startswith(MODRINTH_HOSTS):
|
|
hosts.add("modrinth")
|
|
return hosts
|
|
|
|
|
|
def stage(name, jar, platform=None):
|
|
dest = BUILD / "stage" / name
|
|
shutil.rmtree(dest, ignore_errors=True)
|
|
shutil.copytree(PACK, dest)
|
|
left_out = []
|
|
if platform:
|
|
for path in sorted((dest / "mods").glob("*.pw.toml")):
|
|
meta = tomllib.loads(path.read_text())
|
|
if platform not in platforms_of(meta):
|
|
left_out.append(meta["name"])
|
|
path.unlink()
|
|
shutil.copy2(jar, dest / "mods" / jar.name)
|
|
packwiz("refresh", cwd=dest)
|
|
return dest, left_out
|
|
|
|
|
|
def check_overrides(archive, jar):
|
|
bundled = [n for n in zipfile.ZipFile(archive).namelist()
|
|
if n.endswith(".jar") and Path(n).name != jar.name]
|
|
if bundled:
|
|
sys.exit(f"{archive.name} would bundle third-party jars: {bundled}")
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
parser.add_argument("--skip-mod", action="store_true", help="reuse the last companion mod build")
|
|
args = parser.parse_args()
|
|
|
|
if not args.skip_mod:
|
|
build_mod()
|
|
jar = companion_jar()
|
|
run([sys.executable, str(ROOT / "tools/quests.py")], ROOT) # the quest book (Phase 8) from docs/quests.yaml
|
|
packwiz("refresh", cwd=PACK)
|
|
pack = tomllib.loads((PACK / "pack.toml").read_text())
|
|
base = f"{pack['name'].lower().replace(' ', '-')}-{pack['version']}"
|
|
|
|
stage("full", jar)
|
|
report = {}
|
|
for platform, suffix, command in (("modrinth", ".mrpack", "modrinth"),
|
|
("curseforge", "-curseforge.zip", "curseforge")):
|
|
dest, left_out = stage(platform, jar, platform)
|
|
out = BUILD / f"{base}{suffix}"
|
|
out.unlink(missing_ok=True)
|
|
packwiz(command, "export", "-o", str(out), cwd=dest)
|
|
check_overrides(out, jar)
|
|
report[out.name] = left_out
|
|
|
|
print("\nExports (no third-party jars in overrides):")
|
|
for name, left_out in report.items():
|
|
print(f" build/{name}")
|
|
for mod in left_out:
|
|
print(f" left out, not hosted on this platform: {mod}")
|
|
print(" build/stage/full/pack.toml (all mods; used by Prism sync and the smoke test)")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|