This repository has been archived by the owner on Apr 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
73 lines (62 loc) · 4.51 KB
/
build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# This script generates the instances and creates the zip files in "dist".
# In order for this script to run, 7zip must be added to the system path.
$rootDir = $PWD
$inputDir = Join-Path $rootDir "src"
$outputDir = Join-Path $rootDir "dist"
$baseInstanceDir = Join-Path $inputDir "lf_instance_base"
$baseInstanceFiles = Get-ChildItem $baseInstanceDir -Recurse | Where-Object { ! $_.PSIsContainer }
function GenerateVersion($mc_version, $loader_version, $lwjgl_cachedName, $lwjgl_uid, $lwjgl_version, [switch]$ignorePatches = $false) {
$instanceOutDir = Join-Path $inputDir ("legacy_fabric_" + $mc_version)
foreach ($inputFile in $baseInstanceFiles) {
# get relativ filepath and create directories
Set-Location $baseInstanceDir
$relativeFilePath = Get-Item $inputFile.FullName | Resolve-Path -Relative
$outputFile = Join-Path $instanceOutDir $relativeFilePath
[Collections.ArrayList]$directories = $outputFile.Split([IO.Path]::DirectorySeparatorChar)
$directories.RemoveAt($directories.Count - 1)
if ($ignorePatches -eq $true -and $directories[$directories.Count - 1] -eq "patches") {
continue
}
$directory = $directories -join [IO.Path]::DirectorySeparatorChar
New-Item -ItemType Directory -Force -Path $directory
# insert values in text files and copy other files
if ($inputFile.Name.EndsWith(".cfg") -or $inputFile.Name.EndsWith(".json")) {
$content = Get-Content -Path $inputFile.FullName
for ($i = 0; $i -lt $content.Count; $i++) {
$content[$i] = $content[$i] -replace "{mc_version}", $mc_version
$content[$i] = $content[$i] -replace "{loader_version}", $loader_version
$content[$i] = $content[$i] -replace "{lwjgl_cachedName}", $lwjgl_cachedName
$content[$i] = $content[$i] -replace "{lwjgl_uid}", $lwjgl_uid
$content[$i] = $content[$i] -replace "{lwjgl_version}", $lwjgl_version
}
Set-Content -Path $outputFile -Value $content
}
else {
Copy-Item -Path $inputFile -Destination $outputFile -Force
}
}
}
# to update the loader just change this line and run the script
$loaderVersion = "0.14.8"
GenerateVersion -mc_version "1.13.2" -loader_version $loaderVersion -lwjgl_cachedName "LWJGL 3" -lwjgl_uid "org.lwjgl3" -lwjgl_version "3.1.6"
GenerateVersion -mc_version "1.12.2" -loader_version $loaderVersion -lwjgl_cachedName "LWJGL 2" -lwjgl_uid "org.lwjgl" -lwjgl_version "2.9.4-nightly-20150209"
GenerateVersion -mc_version "1.11.2" -loader_version $loaderVersion -lwjgl_cachedName "LWJGL 2" -lwjgl_uid "org.lwjgl" -lwjgl_version "2.9.4-nightly-20150209"
GenerateVersion -mc_version "1.10.2" -loader_version $loaderVersion -lwjgl_cachedName "LWJGL 2" -lwjgl_uid "org.lwjgl" -lwjgl_version "2.9.4-nightly-20150209"
GenerateVersion -mc_version "1.9.4" -loader_version $loaderVersion -lwjgl_cachedName "LWJGL 2" -lwjgl_uid "org.lwjgl" -lwjgl_version "2.9.4-nightly-20150209"
GenerateVersion -mc_version "1.8.9" -loader_version $loaderVersion -lwjgl_cachedName "LWJGL 2" -lwjgl_uid "org.lwjgl" -lwjgl_version "2.9.4-nightly-20150209"
GenerateVersion -mc_version "1.8" -loader_version $loaderVersion -lwjgl_cachedName "LWJGL 2" -lwjgl_uid "org.lwjgl" -lwjgl_version "2.9.4-nightly-20150209"
GenerateVersion -mc_version "1.7.10" -loader_version $loaderVersion -lwjgl_cachedName "LWJGL 2" -lwjgl_uid "org.lwjgl" -lwjgl_version "2.9.4-nightly-20150209"
GenerateVersion -mc_version "1.6.4" -loader_version $loaderVersion -lwjgl_cachedName "LWJGL 2" -lwjgl_uid "org.lwjgl" -lwjgl_version "2.9.4-nightly-20150209"
GenerateVersion -mc_version "1.5.2" -loader_version $loaderVersion -lwjgl_cachedName "LWJGL 2" -lwjgl_uid "org.lwjgl" -lwjgl_version "2.9.4-nightly-20150209" -ignorePatches
GenerateVersion -mc_version "1.4.7" -loader_version $loaderVersion -lwjgl_cachedName "LWJGL 2" -lwjgl_uid "org.lwjgl" -lwjgl_version "2.9.4-nightly-20150209" -ignorePatches
GenerateVersion -mc_version "1.3.2" -loader_version $loaderVersion -lwjgl_cachedName "LWJGL 2" -lwjgl_uid "org.lwjgl" -lwjgl_version "2.9.4-nightly-20150209" -ignorePatches
# create instance zips
$instanceDirs = Get-ChildItem $inputDir "legacy_fabric_*"
foreach ($dir in $instanceDirs) {
Write-Output "" "-------------------------------------------------------------------------"
Set-Location $dir.FullName
$zipPath = Join-Path $outputDir ($dir.Name + ".zip")
7z a -tzip $zipPath *
}
Set-Location $rootDir
Write-Output "" "Finished creating instances!"