Skip to content

Commit c5550ce

Browse files
authored
Bring basePower to NeoForge 1.21.1
Use the released Base Metals migration hook and MMDLib crushing registry, preserving machine state and the legacy API. The public dependency stack passed the full local qualification and hosted checks.
2 parents 8d9937b + 66fbe6a commit c5550ce

346 files changed

Lines changed: 10457 additions & 4222 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/NativeDependencyPins.psm1‎

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
Set-StrictMode -Version Latest
2+
$ErrorActionPreference = 'Stop'
3+
4+
function Read-NativeProperties([string]$Path) {
5+
$properties = @{}
6+
foreach ($line in Get-Content -LiteralPath $Path) {
7+
if ($line -match '^\s*([^#!\s=]+)\s*=(.*)$') {
8+
$properties[$Matches[1]] = $Matches[2].Trim()
9+
}
10+
}
11+
return $properties
12+
}
13+
14+
function Read-NativeDependencyPins([string]$LockPath, [hashtable]$Properties) {
15+
$lock = Get-Content -LiteralPath $LockPath -Raw | ConvertFrom-Json -AsHashtable
16+
if ($lock.schemaVersion -ne 1) { throw 'Unsupported native dependency lock schema' }
17+
if ($lock.status -ne 'HOSTED_INPUTS_READY') {
18+
throw "BOOTSTRAP_BLOCKED: $($lock.reason)"
19+
}
20+
$target = $lock.target
21+
if ($target.minecraft -ne '1.21.1' -or $target.neoforge -ne '21.1.265' -or
22+
$target.java -ne '21' -or $target.moddev -ne '2.0.148' -or $target.gradle -ne '9.8.0' -or
23+
$target.releaseBranch -ne 'master-1.21.1-neo') { throw 'Wrong native build target' }
24+
if ($Properties.minecraft_version -ne $target.minecraft -or $Properties.neo_version -ne $target.neoforge -or
25+
$Properties.java_version -ne $target.java -or $Properties.loader_name -ne 'neoforge' -or
26+
$Properties.loader_code -ne '2') { throw 'Dependency lock differs from the project target' }
27+
$ids = @($lock.dependencies | ForEach-Object { $_.id } | Sort-Object)
28+
if (($ids -join ',') -ne 'basemetals,mmdlib,orespawn') { throw 'Exactly three unique native dependencies are required' }
29+
$coordinates = @{
30+
basemetals = @('zone.moddev.mc.basemetals', 'BaseMetals', 'basemetals_version', 'basemetals_deobf_sha256')
31+
mmdlib = @('zone.moddev.mc.lib', 'mmdlib', 'mmdlib_version', 'mmdlib_sha256')
32+
orespawn = @('zone.moddev.mc.orespawn', 'OreSpawn', 'orespawn_version', 'orespawn_deobf_sha256')
33+
}
34+
foreach ($pin in $lock.dependencies) {
35+
$expected = $coordinates[$pin.id]
36+
if ($pin.state -ne 'PUBLISHED') { throw "Dependency $($pin.id) is not a published input" }
37+
if ($pin.group -cne $expected[0] -or $pin.artifact -cne $expected[1] -or
38+
$pin.versionProperty -cne $expected[2] -or $pin.hashProperty -cne $expected[3]) {
39+
throw "Unexpected coordinate or project property for $($pin.id)"
40+
}
41+
if ($pin.version -cne $Properties[$pin.versionProperty] -or
42+
$pin.sha256 -cne $Properties[$pin.hashProperty]) { throw "Project pin differs for $($pin.id)" }
43+
if ($pin.sha256 -cnotmatch '^[A-F0-9]{64}$' -or
44+
$pin.mavenVersion -notmatch '^\d+\.\d+\.\d+\.121012(?:\+Neo)?$' -or
45+
$pin.mavenVersion -cnotin @($pin.version, ($pin.version + '+Neo')) -or
46+
$pin.modVersion -cne $pin.mavenVersion -or
47+
[string]::IsNullOrWhiteSpace($pin.modVersion) -or
48+
$pin.modVersion -match '(?i)development|snapshot|unqualified') {
49+
throw "Missing exact public native artifact identity for $($pin.id)"
50+
}
51+
if ($pin.ContainsKey('source')) {
52+
$source = $pin.source
53+
if ($source.repository -cne "MinecraftModDevelopmentMods/$($pin.artifact)" -or
54+
$source.commit -cnotmatch '^[a-f0-9]{40}$' -or
55+
$source.branch -notmatch '^master-1\.21\.1(?:-neo|-neoforge)?$') {
56+
throw "Missing approved source ancestry pin for $($pin.id)"
57+
}
58+
$property = "$($pin.id)_source_commit"
59+
if (!$Properties.ContainsKey($property) -or $Properties[$property] -cne $source.commit) {
60+
throw "Project source pin differs for $($pin.id)"
61+
}
62+
} elseif ($pin.id -eq 'basemetals') { throw 'Base Metals hook requires an exact merged source pin' }
63+
if ($pin.id -eq 'basemetals' -and $pin.requiredEntry -cne 'zone/moddev/mc/basemetals/migration/LegacyWorldDataHook.class') {
64+
throw 'Base Metals migration-hook gate was removed'
65+
}
66+
}
67+
return $lock
68+
}
69+
70+
function Assert-NativeSourceAncestry($Pin, [scriptblock]$Compare = {
71+
param($Uri)
72+
$status = & gh api $Uri --jq '.status'
73+
if ($LASTEXITCODE -ne 0) { throw 'GitHub source comparison failed' }
74+
return $status
75+
}) {
76+
if (!$Pin.ContainsKey('source')) { return }
77+
$source = $Pin.source
78+
$uri = "repos/$($source.repository)/compare/$($source.commit)...$($source.branch)"
79+
$status = & $Compare $uri
80+
if ($status -notin @('identical', 'ahead')) {
81+
throw "Source $($source.commit) is not merged on $($source.branch): $status"
82+
}
83+
}
84+
85+
function Assert-NativeDependencyArchive([string]$Path, $Pin) {
86+
if ((Get-FileHash -LiteralPath $Path -Algorithm SHA256).Hash -cne $Pin.sha256) {
87+
throw "SHA-256 mismatch for $($Pin.id)"
88+
}
89+
Add-Type -AssemblyName System.IO.Compression.FileSystem
90+
$archive = [IO.Compression.ZipFile]::OpenRead($Path)
91+
try {
92+
$entry = $archive.GetEntry('META-INF/neoforge.mods.toml')
93+
if (!$entry -or $archive.GetEntry('META-INF/mods.toml')) { throw "Not a native NeoForge jar: $($Pin.id)" }
94+
$reader = [IO.StreamReader]::new($entry.Open())
95+
try { $metadata = $reader.ReadToEnd() } finally { $reader.Dispose() }
96+
$header = [regex]::Match($metadata, '(?ms)^[ \t]*\[\[mods\]\][ \t]*(?:#[^\r\n]*)?\r?\n(.*?)(?=^[ \t]*\[|\z)').Groups[1].Value
97+
$id = [regex]::Escape($Pin.id)
98+
$version = [regex]::Escape($Pin.modVersion)
99+
if ($metadata -match '\$\{[^}]+\}' -or
100+
$header -notmatch "(?m)^[ \t]*modId[ \t]*=[ \t]*`"$id`"[ \t]*(?:#[^\r\n]*)?\r?$" -or
101+
$header -notmatch "(?m)^[ \t]*version[ \t]*=[ \t]*`"$version`"[ \t]*(?:#[^\r\n]*)?\r?$" -or
102+
$metadata -notmatch '(?m)^[ \t]*modId[ \t]*=[ \t]*"neoforge"[ \t]*(?:#[^\r\n]*)?\r?$') {
103+
throw "Jar metadata differs for $($Pin.id)"
104+
}
105+
if ($Pin.ContainsKey('requiredEntry') -and !$archive.GetEntry($Pin.requiredEntry)) {
106+
throw 'Base Metals jar does not contain the approved migration hook'
107+
}
108+
} finally { $archive.Dispose() }
109+
}
110+
111+
Export-ModuleMember -Function Read-NativeProperties, Read-NativeDependencyPins, Assert-NativeSourceAncestry, Assert-NativeDependencyArchive

‎.github/native-dependencies.json‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"schemaVersion": 1,
3+
"status": "HOSTED_INPUTS_READY",
4+
"reason": "All three dependencies are public. Base Metals PR #545 is merged and its release jar matches CurseForge, Maven and GitHub downloads.",
5+
"target": {
6+
"minecraft": "1.21.1",
7+
"neoforge": "21.1.265",
8+
"java": "21",
9+
"moddev": "2.0.148",
10+
"gradle": "9.8.0",
11+
"releaseBranch": "master-1.21.1-neo"
12+
},
13+
"dependencies": [
14+
{
15+
"id": "basemetals",
16+
"group": "zone.moddev.mc.basemetals",
17+
"artifact": "BaseMetals",
18+
"versionProperty": "basemetals_version",
19+
"hashProperty": "basemetals_deobf_sha256",
20+
"version": "4.0.1.121012+Neo",
21+
"mavenVersion": "4.0.1.121012+Neo",
22+
"modVersion": "4.0.1.121012+Neo",
23+
"sha256": "B4BB1CBCD54DFCF2EC8465ACE82715EDCCC5BF1E5C15E14C627AE7CC58E8FED1",
24+
"state": "PUBLISHED",
25+
"source": {
26+
"repository": "MinecraftModDevelopmentMods/BaseMetals",
27+
"branch": "master-1.21.1-neo",
28+
"commit": "39b240bb0d9f80997847ab4df70a2dd23e6ea826",
29+
"baselineCommit": "4d63af931292e5020a5e0a3ddbd73a87ab1f410f"
30+
},
31+
"requiredEntry": "zone/moddev/mc/basemetals/migration/LegacyWorldDataHook.class"
32+
},
33+
{
34+
"id": "mmdlib",
35+
"group": "zone.moddev.mc.lib",
36+
"artifact": "mmdlib",
37+
"versionProperty": "mmdlib_version",
38+
"hashProperty": "mmdlib_sha256",
39+
"version": "2.0.2.121012+Neo",
40+
"mavenVersion": "2.0.2.121012+Neo",
41+
"modVersion": "2.0.2.121012+Neo",
42+
"sha256": "EE417C82D588B0050A49709B6430CF836315E71E4DB2DF4036D3735454BC5311",
43+
"state": "PUBLISHED"
44+
},
45+
{
46+
"id": "orespawn",
47+
"group": "zone.moddev.mc.orespawn",
48+
"artifact": "OreSpawn",
49+
"versionProperty": "orespawn_version",
50+
"hashProperty": "orespawn_deobf_sha256",
51+
"version": "4.1.1.121012",
52+
"mavenVersion": "4.1.1.121012",
53+
"modVersion": "4.1.1.121012",
54+
"sha256": "BF02244E25B5FBF89CCAD45F41B2624B850D4BBCB70CF66822249BA233A00976",
55+
"state": "PUBLISHED",
56+
"source": {
57+
"repository": "MinecraftModDevelopmentMods/OreSpawn",
58+
"branch": "master-1.21.1-neo",
59+
"commit": "f141ae56ea69e4c9f7f8ebd7697b933a91ee5001"
60+
}
61+
}
62+
]
63+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import groovy.json.JsonSlurper
2+
import java.security.MessageDigest
3+
4+
allprojects {
5+
afterEvaluate { project ->
6+
def lock = new JsonSlurper().parse(project.file('.github/native-dependencies.json'))
7+
if (lock.status != 'HOSTED_INPUTS_READY') {
8+
throw new GradleException('Hosted dependency bootstrap is blocked; local hook hashes are not release pins')
9+
}
10+
def arguments = [basemetals: 'baseMetalsJar', mmdlib: 'mmdlibJar', orespawn: 'oreSpawnJar']
11+
def resolved = [:]
12+
lock.dependencies.each { pin ->
13+
def path = project.providers.gradleProperty(arguments[pin.id]).orNull
14+
if (!path) throw new GradleException('Missing pinned dependency path: ' + pin.id)
15+
File jar = project.file(path)
16+
String actual = jar.isFile() ? MessageDigest.getInstance('SHA-256').digest(jar.bytes)
17+
.encodeHex().toString().toUpperCase(Locale.ROOT) : ''
18+
if (pin.state != 'PUBLISHED' || actual != pin.sha256
19+
|| project.property(pin.versionProperty) != pin.version
20+
|| project.property(pin.hashProperty) != pin.sha256) {
21+
throw new GradleException('Changed or unapproved hosted input: ' + pin.id)
22+
}
23+
resolved[pin.id] = jar
24+
}
25+
// Use exactly the verified files rather than independently resolving Maven bytes again.
26+
project.configurations.configureEach {
27+
withDependencies { dependencies ->
28+
dependencies.removeAll { dependency -> lock.dependencies.any { pin ->
29+
dependency.group == pin.group && dependency.name == pin.artifact
30+
} }
31+
}
32+
}
33+
project.dependencies.add('pinnedBaseMetals', project.files(resolved.basemetals))
34+
project.dependencies.add('implementation', project.files(resolved.mmdlib, resolved.orespawn))
35+
}
36+
}

‎.github/test-base-metals-pin.sh‎

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,3 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
3-
4-
verify="$(cd "$(dirname "$0")" && pwd)/verify-base-metals-pin.sh"
5-
temporary_root="$(cd "${TMPDIR:-/tmp}" && pwd -P)"
6-
scratch="$(mktemp -d "$temporary_root/basepower-pin.XXXXXXXX")"
7-
cleanup() {
8-
local resolved
9-
resolved="$(cd "$scratch" && pwd -P)"
10-
case "$resolved" in
11-
"$temporary_root"/basepower-pin.*) rm -rf -- "$resolved" ;;
12-
*) echo 'Refusing to clear an unexpected test directory' >&2; return 1 ;;
13-
esac
14-
}
15-
trap cleanup EXIT
16-
mkdir -p "$scratch/bin" "$scratch/project"
17-
cat > "$scratch/bin/gh" <<'MOCK'
18-
#!/usr/bin/env bash
19-
set -euo pipefail
20-
[[ "$#" == 4 && "$1" == api && "$2" == "$EXPECTED_COMPARE" && "$3" == --jq && "$4" == .status ]]
21-
printf '%s\n' "$PIN_STATUS"
22-
MOCK
23-
chmod +x "$scratch/bin/gh"
24-
export PATH="$scratch/bin:$PATH"
25-
commit=1111111111111111111111111111111111111111
26-
cd "$scratch/project"
27-
for minecraft in 1.20.6 1.21.1 1.21.11; do
28-
printf 'minecraft_version=%s\nbasemetals_source_commit=%s\n' "$minecraft" "$commit" > gradle.properties
29-
export EXPECTED_COMPARE="repos/MinecraftModDevelopmentMods/BaseMetals/compare/$commit...master-$minecraft"
30-
export GITHUB_OUTPUT="$scratch/output"
31-
for PIN_STATUS in identical ahead; do
32-
export PIN_STATUS
33-
: > "$GITHUB_OUTPUT"
34-
bash "$verify"
35-
grep -qx "commit=$commit" "$GITHUB_OUTPUT"
36-
done
37-
for PIN_STATUS in behind diverged; do
38-
export PIN_STATUS
39-
: > "$GITHUB_OUTPUT"
40-
if bash "$verify" > "$scratch/rejected.log" 2>&1; then
41-
echo "Incorrectly accepted $minecraft / $PIN_STATUS" >&2
42-
exit 1
43-
fi
44-
test ! -s "$GITHUB_OUTPUT"
45-
done
46-
done
47-
printf 'minecraft_version=invalid\nbasemetals_source_commit=%s\n' "$commit" > gradle.properties
48-
if bash "$verify" > "$scratch/invalid.log" 2>&1; then
49-
echo 'Incorrectly accepted an invalid target' >&2
50-
exit 1
51-
fi
52-
echo 'PASS: target-derived Base Metals ancestry guards and rejection controls'
3+
exec pwsh -NoProfile -File "$(dirname "$0")/test-native-dependencies.ps1" "$@"

0 commit comments

Comments
 (0)