Skip to content

Commit

Permalink
Update for ATM7
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremiahwinsley committed Sep 4, 2022
1 parent b76eb43 commit 306184a
Show file tree
Hide file tree
Showing 6 changed files with 275 additions and 4 deletions.
65 changes: 65 additions & 0 deletions compare7.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
$ErrorActionPreference = "Stop"

$source = "C:\Games\CurseForge\Minecraft\Instances\All_The_Mods_7\mods\"
$multimc = "C:\Games\CurseForge\Minecraft\Instances\All the Mods 7 - ATM7 - 1.18.2\mods"


if ( -Not (Test-Path $source)) {
Write-Host "No CurseForge instance found with the name All_The_Mods_7" -ForegroundColor Red
exit 1
}

if ( -Not (Test-Path $multimc)) {
Write-Host "No CurseForge instance found with the name All the Mods 7 - ATM7 - 1.18.2" -ForegroundColor Red
exit 1
}

$newMods = Get-ChildItem $source -Filter "*.jar"
$oldMods = Get-ChildItem $multimc -Filter "*.jar"
$added = [System.Collections.ArrayList]::new();
$updated = [System.Collections.ArrayList]::new();
$removed = [System.Collections.ArrayList]::new($oldMods)

foreach($mod in $newMods) {
$modFilename = [System.IO.Path]::GetFileName($mod.FullName);
$slug = $modFilename -replace '[^a-zA-Z_]+','' -replace 'forge|hotfix|RELEASE|BETA|ALPHA','';
$matched = $false;
foreach($oldMod in $oldMods) {
$oldFilename = [System.IO.Path]::GetFileName($oldMod.FullName)
$oldSlug = $oldFilename -replace '[^a-zA-Z_]+','' -replace 'forge|hotfix|RELEASE|BETA|ALPHA','';
if ($slug -eq $oldSlug) {
$matched = $true;
if ($modFilename -ne $oldFilename) {
$updated.Add($modFilename) | Out-Null
}
$removed.Remove($oldMod)
break;
}
}

if ($matched -eq $false) {
$added.Add($modFilename) | Out-Null
}
}


# render
if ($added.Length -gt 0) {
Write-Output "### Mod Additions"
foreach ($name in $added) {
Write-Output "- $name"
}
}
if ($updated.Length -gt 0) {
Write-Output "### Mod Updates"
foreach ($name in $updated) {
Write-Output "- $name"
}
}
if ($removed.Length -gt 0) {
Write-Output "### Mod Removals"
foreach ($mod in $removed) {
$name = [System.IO.Path]::GetFileName($mod.FullName)
Write-Output "- $name"
}
}
152 changes: 152 additions & 0 deletions export7.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
param([string]$version = "")
$ErrorActionPreference = "Stop"

$source = "C:\Games\CurseForge\Minecraft\Instances\All_The_Mods_7"
$overridePath = "$PSScriptRoot\overrides"
$manifestPath = "$PSScriptRoot\manifest.json"
$serverPath = "$PSScriptRoot\server"
$cachePath = "$PSScriptRoot\cache"
$tmpPath = "$PSScriptRoot\tmp"
$modsPath = "$tmpPath\mods"
$batPath = "$tmpPath\startserver.bat"
$shPath = "$tmpPath\startserver.sh"

$ignore = @(
"263420", # Xaero's Minimap
"317780", # Xaero's World Map
"232131", # Default Options
"231275", # Ding
"367706", # FancyMenu
"261725", # ItemZoom
"243863", # No Potion Shift
"305373", # Reload Audio Driver
"325492", # Light Overlay
"296468", # NoFog
"308240", # Cherished Worlds
"362791", # Cull Particles
"291788", # Server Tab Info
"326950", # Screenshot to Clipboard
"237701", # ReAuth
"391382", # MoreOverlays
"358191", # PackMenu
"271740", # Toast Control
"428199", # Out Of Sight
"431430", # FlickerFix
"240630", # Just Enough Resources
"532127", # Legendary Tooltips
"499826", # Advancement Plaques
"60089" , # Mouse Tweaks
"446253", # Better Biome Blend
"502561", # Equipment Compare
"448233", # Entity Culling
"280294" # FPS Reducer
)

if ( -Not (Test-Path $source)) {
Write-Host "No CurseForge instance found with the name All_The_Mods_7" -ForegroundColor Red
exit 1
}

if ( -Not (Test-Path $overridePath)) {
Write-Host "Cloning configuration repo."
git clone --branch Staging --depth 1 --single-branch https://github.com/AllTheMods/ATM-7.git $overridePath
}

Get-ChildItem $overridePath -Exclude "config", "defaultconfigs", "kubejs", "packmenu" | Remove-Item -Recurse

if ($version.Length -eq 0) {
$tweaks = "$overridePath\config\allthetweaks-common.toml"
$version = @("major", "minor", "minorrev") | ForEach-Object {
Select-String -Path $tweaks -Pattern "$_ = (\d+)" | ForEach-Object {$_.matches.Groups[1].value}
} | Join-String -Separator "."
}

Write-Host "Loading CurseForge manifest..."
Write-HOST "If you have added any mods, you MUST run the game once to update the Curseforge instance JSON.".
$instancePath = "$source\minecraftinstance.json"
$instanceJson = Get-Content $instancePath -raw | ConvertFrom-Json

$forgeVersion = $instanceJson.baseModLoader.forgeVersion;
Write-Host "Manifest uses Forge $forgeVersion."

# start generate server pack

$serverDest = "ATM7-dev-$version-server.zip"
Write-Host "Writing server zip to: $serverDest"

if (Test-Path $serverDest) {
Write-Host "Removing existing export."
Remove-Item $serverDest
}


New-Item -Path $modsPath -Type Directory -Force | Out-Null
foreach($mod in $instanceJson.installedAddons) {
if (-Not ($ignore -contains $mod.addonID)) {
$filename = $mod.installedFile.FileNameOnDisk
Copy-Item -LiteralPath "$source\mods\$filename" -Destination "$modsPath\$filename"
}
}

Get-Content "$PSScriptRoot\templates\startserver-template-18.bat" -raw | % {$_.replace('@version@', $forgeVersion)} | Set-Content -NoNewline $batPath
Get-Content "$PSScriptRoot\templates\startserver-template-18.sh" -raw | % {$_.replace('@version@', $forgeVersion)} | Set-Content -NoNewline $shPath

$compress = @{
Path = @(
"$overridePath/config",
"$overridePath/defaultconfigs",
"$overridePath/kubejs",
"$tmpPath/*"
)
CompressionLevel = "Fastest"
DestinationPath = $serverDest
}
ls "$tmpPath/*"
Compress-Archive @compress

Write-Host "Created server archive - cleaning up."
Remove-Item -Recurse -Force -Path $tmpPath

# end generate server pack
# start generate client pack

Write-Host "Generating manifest for version: $version"
$manifestJson = Get-Content "$PSScriptRoot\templates\manifest-template-atm7.json" -raw | ConvertFrom-Json

$manifestJson.minecraft.modLoaders[0].id = "forge-${forgeVersion}"
$manifestJson.version = $version

foreach($mod in $instanceJson.installedAddons) {
$manifestJson.files += @{
projectID = $mod.addonID
fileID = $mod.installedFile.id
required = $true
}
}

$manifestJson | ConvertTo-Json -Depth 32 | Set-Content $manifestPath

$dest = "ATM7-dev-$version.zip";
Write-Host "Writing client zip to: $dest"

if (Test-Path $dest) {
Write-Host "Removing existing export."
Remove-Item $dest
}

$compress = @{
Path = $manifestPath, $overridePath
CompressionLevel = "Fastest"
DestinationPath = $dest
}

Compress-Archive @compress

Write-Host "Created client archive - cleaning up."

Remove-Item -Recurse -Force -Path $overridePath
Remove-Item -Recurse -Force -Path $manifestPath

# end generate client pack

Write-Host "Finished."
27 changes: 27 additions & 0 deletions import7.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
$ErrorActionPreference = "Stop"

$source = "C:\Games\CurseForge\Minecraft\Instances\All_The_Mods_7"
$overridePath = "$PSScriptRoot\overrides"

if ( -Not (Test-Path $source)) {
Write-Host "No CurseForge instance found with the name All_The_Mods_7" -ForegroundColor Red
exit 1
}

if ( -Not (Test-Path $overridePath)) {
Write-Host "Cloning configuration repo."
git clone --branch Staging --depth 1 --single-branch https://github.com/AllTheMods/ATM-7.git $overridePath
}

Get-ChildItem $overridePath -Exclude "config", "defaultconfigs", "kubejs", "packmenu" | Remove-Item -Recurse

Write-Host "Removing existing configuration."
Get-ChildItem $source -Include "config", "defaultconfigs", "kubejs", "packmenu" -Recurse -Depth 0 | Remove-Item -Recurse

Write-Host "Copying new configuration."
Copy-Item -Recurse -Path "$overridePath/*" -Include "config", "defaultconfigs", "kubejs", "packmenu" -Destination $source

Write-Host "Cleaning up."
Remove-Item -Recurse -Force -Path $overridePath | Out-Null
Write-Host "Finished."

18 changes: 18 additions & 0 deletions templates/manifest-template-atm7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"minecraft": {
"version": "1.18.2",
"modLoaders": [
{
"id": "forge-@version@",
"primary": true
}
]
},
"manifestType": "minecraftModpack",
"overrides": "overrides",
"manifestVersion": 1,
"version": "@version@",
"author": "ATM Team",
"name": "All The Mods 7",
"files": []
}
7 changes: 7 additions & 0 deletions templates/startserver-template-18.bat
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ if not exist "libraries" (
"%ATM7_JAVA%" -jar %INSTALLER% -installServer
)

if not exist "server.properties" (
(
echo allow-flight=true
echo motd=All the Mods 7
)> "server.properties"
)

:START
"%ATM7_JAVA%" -Xmx%MAX_RAM% -Xms%MIN_RAM% -XX:+UseZGC @libraries/net/minecraftforge/forge/1.18.2-%FORGE_VERSION%/win_args.txt nogui

Expand Down
10 changes: 6 additions & 4 deletions templates/startserver-template-18.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ if [ ! -d libraries ]; then
echo "Forge not installed, installing now."
if [ ! -f "$INSTALLER" ]; then
echo "No Forge installer found, downloading now."
which wget >> /dev/null
if [ $? -eq 0 ]; then
if command -v wget >/dev/null 2>&1; then
echo "DEBUG: (wget) Downloading $FORGE_URL"
wget -O "$INSTALLER" "$FORGE_URL"
else
which curl >> /dev/null
if [ $? -eq 0 ]; then
if command -v curl >/dev/null 2>&1; then
echo "DEBUG: (curl) Downloading $FORGE_URL"
curl -o "$INSTALLER" -L "$FORGE_URL"
else
Expand All @@ -52,6 +50,10 @@ if [ ! -d libraries ]; then
"${ATM7_JAVA:-java}" -jar "$INSTALLER" -installServer
fi

if [ ! -e server.properties ]; then
echo -e "allow-flight=true\nmotd=All the Mods 7" > server.properties
fi

while true
do
"${ATM7_JAVA:-java}" -Xmx$MAX_RAM -Xms$MIN_RAM -XX:+UseZGC @libraries/net/minecraftforge/forge/1.18.2-$FORGE_VERSION/unix_args.txt nogui
Expand Down

0 comments on commit 306184a

Please sign in to comment.