Cobblemon Survival Pack: phases 0-2 and Phase 3 zones and hazards
Free NeoForge 1.21.1 modpack on Cobblemon 1.8.4 built with packwiz, plus the Kotlin companion mod (cobblesurvival) and its built-in data pack. - Phase 0: packwiz pack with Modrinth/CurseForge cross-links, build and export tooling, Prism instance sync, test server with smoke checks. - Phase 1: Poke Ball shaped island (WorldGen Editor preset, seed isle-26), Adrian's biome list, no natural ore, structures without ore or vanilla mobs, no Nether portals, world template builder and world report. - Phase 2: permadeath (CobbleHardcoreMon plus the companion mod's gap fixes), Revival Charm, expensive Healing Machine, Lootr refreshing loot, in-game self-tests on Minecraft's GameTest framework. - Phase 3 so far: 14 zones with their own spawn pools and level bands (tools/zone_layout.py, tools/zone_spawns.py, "zone" spawn condition), Cold Sweat heat and cold as gates with boss-drop insulation recipes, spawn survey and hazard self-tests in tools/quick_check.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
398301f0be
232 files changed
+72665
No files matched your search
+131
@@ -0,0 +1,131 @@
|
||||
#!/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()
|
||||
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()
|
||||
Reference in new issue
Block a user