SciCraft/tools/patches/build_patched_coe.sh
MiTHRAL be6fa51900
All checks were successful
Build & Release Pack / build (push) Successful in 1m50s
fix: patch Create Ore Excavation kubejs_create wrapper race + validate remote URLs
- COE 1.6.8 races kubejs-create for the ProcessingOutput rhino wrapper
  (guard flag set in @Mod ctor, KubeJS plugin callbacks run during its own
  construction) → nondeterministic 'Wrapper already exists!' boot crash.
  Ship ASM-patched jar (tools/patches/build_patched_coe.sh, Patcher.java).
- validate_pack.py: new 'remote' command — fetches every direct URL and
  byte-verifies non-CDN hashes; catches unpushed/ drifted patched jars.
- docs/server.md: stale-metadata failure row (-g is GUI-only), patched-jars
  table; docs/mods.md compat notes.
2026-08-24 14:17:35 -04:00

49 lines
2.2 KiB
Bash

#!/usr/bin/env bash
# SCICRAFT — rebuild createoreexcavation with the kubejs-create wrapper race fixed.
#
# Why: COE 1.21.1-1.6.8 decides in KubeJSExcavation.registerTypeWrappers whether to
# register its own ProcessingOutput rhino wrapper, based on a flag set in the @Mod
# constructor. KubeJS runs plugin callbacks during ITS construction; FML constructs
# independent mods on parallel workers → race. If the callback wins, both COE and
# kubejs-create register ProcessingOutput → "Wrapper already exists!" boot crash.
#
# Fix: this pack always ships kubejs-create (scripts use event.recipes.create.*),
# so strip COE's guarded registration entirely via ASM (see Patcher.java).
#
# Usage: tools/patches/build_patched_coe.sh (from repo root)
set -euo pipefail
cd "$(dirname "$0")"
COE_URL="https://cdn.modrinth.com/data/ResbpANg/versions/tivxiPTo/createoreexcavation-1.21-1.6.8.jar"
OUT_JAR="createoreexcavation-1.21-1.6.8-patched.jar"
WORK="$(mktemp -d)"
trap 'rm -rf "$WORK"' EXIT
echo "[patch] downloading original..."
curl -fsSL -o "$WORK/coe.jar" "$COE_URL"
unzip -q "$WORK/coe.jar" "com/tom/createores/kubejs/KubeJSExcavation.class" -d "$WORK/x"
if [ ! -f asm.jar ]; then
echo "[patch] fetching ASM..."
curl -fsSL -o asm.jar https://repo1.maven.org/maven2/org/ow2/asm/asm/9.7.1/asm-9.7.1.jar
curl -fsSL -o asm-tree.jar https://repo1.maven.org/maven2/org/ow2/asm/asm-tree/9.7.1/asm-tree-9.7.1.jar
fi
echo "[patch] compiling + running patcher..."
javac -cp asm.jar:asm-tree.jar Patcher.java
java -cp .:asm.jar:asm-tree.jar Patcher \
"$WORK/x/com/tom/createores/kubejs/KubeJSExcavation.class" \
"$WORK/KubeJSExcavation.class"
echo "[patch] rebuilding jar..."
cp "$WORK/coe.jar" "$OUT_JAR"
mkdir -p "$WORK/stage/com/tom/createores/kubejs"
cp "$WORK/KubeJSExcavation.class" "$WORK/stage/com/tom/createores/kubejs/"
(cd "$WORK/stage" && jar uf "$OLDPWD/$OUT_JAR" com)
echo "[patch] verifying: patched class inside jar differs, rest untouched..."
unzip -p "$OUT_JAR" com/tom/createores/kubejs/KubeJSExcavation.class > "$WORK/after.class"
cmp -s "$WORK/x/com/tom/createores/kubejs/KubeJSExcavation.class" "$WORK/after.class" \
&& { echo "[patch] ERROR: class unchanged"; exit 1; }
sha512sum "$OUT_JAR"
echo "[patch] done → $OUT_JAR"