From bbba58d1ddef4fca62e054ae292c79ceb7e96b9f Mon Sep 17 00:00:00 2001 From: Matt Sijbers Date: Sat, 9 May 2026 22:30:49 +0100 Subject: [PATCH] fix: tweak jars use forward-slash entry names; bump pack to 0.9.3 NeoForge's mod scanner rejected brassandsigil_tweaks-1.0.0.jar because PowerShell 5.1's [ZipFile]::CreateFromDirectory() writes Windows-native path separators into ZIP entry names on Windows. Entries came out as "META-INF\neoforge.mods.toml" instead of the spec-required forward-slash form, so the loader couldn't find the manifest and silently dropped the jar with "not a valid mod file". Build-Tweaks.ps1 now opens the archive in 'Create' mode and writes each file as an explicit ZipArchiveEntry whose name is built from the relative path with backslashes replaced by forward slashes. Verified the rebuilt jar lists "META-INF/neoforge.mods.toml" etc. Pack version 0.9.2 -> 0.9.3 so launchers cached at 0.9.2 see "pack changed" and re-sync the new tweak jar (their bytes differ; SHA-1 in the manifest will reflect that). --- pack/pack.lock.json | 2 +- scripts/Build-Tweaks.ps1 | 27 +++++++++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/pack/pack.lock.json b/pack/pack.lock.json index c8b03bf..5330146 100644 --- a/pack/pack.lock.json +++ b/pack/pack.lock.json @@ -1,7 +1,7 @@ { "$schema": "Brass-and-Sigil pack.lock.json - generated, do not edit by hand unless you know what you are doing", "name": "Brass and Sigil", - "version": "0.9.2", + "version": "0.9.3", "minecraft": "1.21.1", "loader": { "type": "neoforge", diff --git a/scripts/Build-Tweaks.ps1 b/scripts/Build-Tweaks.ps1 index 4e8d819..763b1a8 100644 --- a/scripts/Build-Tweaks.ps1 +++ b/scripts/Build-Tweaks.ps1 @@ -100,12 +100,27 @@ foreach ($dir in $tweakDirs) { if (Test-Path $jarPath) { Remove-Item $jarPath -Force } - [System.IO.Compression.ZipFile]::CreateFromDirectory( - $dir.FullName, - $jarPath, - [System.IO.Compression.CompressionLevel]::Optimal, - $false - ) + # NB: PowerShell 5.1's [ZipFile]::CreateFromDirectory() writes Windows- + # native path separators (\) into ZIP entry names on Windows, producing + # entries like "META-INF\neoforge.mods.toml" instead of the spec-required + # "META-INF/neoforge.mods.toml". NeoForge's mod scanner then can't find + # the manifest and silently rejects the jar with "not a valid mod file". + # We build the archive manually so we control the entry name format. + # 'Create' string maps to ZipArchiveMode.Create -- PowerShell 5.1 doesn't + # auto-load the enum type, so the literal string form is more portable. + $zip = [System.IO.Compression.ZipFile]::Open($jarPath, 'Create') + try { + $sourceLen = $dir.FullName.Length + Get-ChildItem -Path $dir.FullName -Recurse -File | ForEach-Object { + $relPath = $_.FullName.Substring($sourceLen).TrimStart('\','/').Replace('\','/') + $entry = $zip.CreateEntry($relPath, [System.IO.Compression.CompressionLevel]::Optimal) + $entryStream = $entry.Open() + try { + $bytes = [System.IO.File]::ReadAllBytes($_.FullName) + $entryStream.Write($bytes, 0, $bytes.Length) + } finally { $entryStream.Dispose() } + } + } finally { $zip.Dispose() } $size = (Get-Item $jarPath).Length Write-Host (" built {0,-40} {1,8:N0} bytes" -f $jarName, $size)