#!/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"