2026-09-13 09:16:42 +03:00
param ([ string ] $ServerRoot = 'C:\Users\ScarPC\Documents\NeoForge Server 26.2' ,[ switch ] $Experimental )
$ErrorActionPreference = 'Stop'
$project =( Resolve-Path " $PSScriptRoot /.." ). Path
$output = Join-Path $project ( 'build/verification-' +( Get-Date -Format 'yyyyMMdd-HHmmss' ))
New-Item -ItemType Directory -Path " $output /mods" , " $output /config" | Out-Null
$runtime =( Resolve-Path -LiteralPath $ServerRoot ). Path . Replace ( '\' , '/' )
$lines =( Get-Content -Raw " $runtime /libraries/net/neoforged/neoforge/26.2.0.79/win_args.txt" ). Replace ( 'libraries/' ,( $runtime + '/libraries/' )) -split " `r ? `n "
for ( $i = 0 ; $i -lt $lines . Length ; $i ++) {
if ( $lines [ $i ]. StartsWith ( '-DlibraryDirectory=' )){ $lines [ $i ]= '"-DlibraryDirectory=' + $runtime + '/libraries"' }
if ( $i -gt 0 -and $lines [ $i - 1 ] -eq '-classpath' ){ $lines [ $i ]= '"' + $lines [ $i ]+ '"' }
}
$lines | Set-Content " $output /server-args.txt"
'eula=true' | Set-Content " $output /eula.txt"
@'
server-ip=127.0.0.1
server-port=26783
online-mode=false
level-type=minecraft:flat
generate-structures=false
view-distance=2
simulation-distance=2
spawn-protection=0
max-tick-time=120000
'@ | Set-Content " $output /server.properties"
if ( $Experimental ){ 'initial-enabled-packs=vanilla,minecart_improvements' | Add-Content " $output /server.properties" }
'{"build":{"onStartup":false},"astraPacks":{"enabled":false},"editor":{"enabled":false}}' | Set-Content " $output /config/astraplus.json"
$plus = Get-ChildItem -LiteralPath " $ServerRoot /mods" -Filter 'AstraPlus-*.jar' | Where-Object Name -NotMatch 'sources|api|verification'
if ( @ ( $plus ). Count -ne 1 ){ throw 'Expected exactly one installed AstraPlus JAR' }
2026-09-13 09:38:31 +03:00
Copy-Item -LiteralPath $plus . FullName , " $project /build/libs/AstraContent-0.2.0.jar" , " $project /build/libs/AstraContent-0.2.0-verification.jar" -Destination " $output /mods"
2026-09-13 09:16:42 +03:00
Push-Location $output
try {
foreach ( $pass in @ ( 'gameplay' , 'restart' )) {
& 'C:/Users/ScarPC/.gradle/jdks/eclipse_adoptium-25-amd64-windows.2/bin/java.exe' '-Xmx2G' '-Dastracontent.verify=true' "-Dastracontent.expectedExperimental= $( $Experimental . IsPresent . ToString (). ToLowerInvariant ()) " '@server-args.txt' nogui *> " $pass .log"
if ( $LASTEXITCODE -ne 0 ){ throw "Server failed: $output / $pass .log" }
2026-09-13 09:38:31 +03:00
if ( Select-String -Quiet -LiteralPath " $pass .log" -Pattern 'Exception stopping the server|Encountered an unexpected exception|Failed to save chunk|Mixin apply failed' ){ throw "Server lifecycle failed: $output / $pass .log" }
2026-09-13 09:16:42 +03:00
$result = Get-Content -Raw verification-result . txt
if (! $result . StartsWith ( "PASS $pass " )){ throw "Verification failed: $result ( $output / $pass .log)" }
Copy-Item verification-result . txt " $pass -result.txt"
Write-Output $result . Trim ()
}
} finally { Pop-Location }
Write-Output "Evidence: $output "