init and some qol stuff for a modpack maker

This commit is contained in:
Joey Eamigh
2023-06-20 20:54:41 -04:00
commit 1160a10a3a
15 changed files with 460 additions and 0 deletions

3
.envrc Normal file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
source .venv/bin/activate

17
.gitignore vendored Normal file
View File

@@ -0,0 +1,17 @@
### PAX ###
pax
pax.exe
libssl*.dll
libcrypto*.dll
cacert.pem
### Modpack ###
.out/
.dist/
# python
.venv
# client
client/.version
client/curseforge

7
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,7 @@
{
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"python.formatting.provider": "none",
"python.analysis.typeCheckingMode": "basic"
}

24
README.md Normal file
View File

@@ -0,0 +1,24 @@
# FishPog Pixelmon
This is the repo for FishPog Pixelmon, and a bit of experimental tooling to make my life easier in designing, updating, and getting non-technical people to be able to easily install the modpack, all without having to use curseforge.
## Building the modpack
```bash
git clone https://git.233hfd.com/joey/FishPogPixelmon.git
cd FishPogPixelmon
source ./venv.sh # or just venv.bat on windows
python tooling.py --setup
```
now, pax will be installed, which will allow you to edit the modpack. refer to the pax github for more info.
## exporting the modpack
```bash
python tooling.py --export
```
this command will package up the pack with pax, then bundle some scripts with it that allows for auto-updating and automatically downloading the mods from curseforge, rather than having to distribute a large zip file.

46
client/client.ps1 Normal file
View File

@@ -0,0 +1,46 @@
# check if winget is installed and if so, set a flag to true
$winget = Get-Command winget -ErrorAction SilentlyContinue
if (!$winget) {
Write-Host "Error: winget is not installed." -Foreground Red
Write-Host "This script may not work withotu winget." -Foreground Red
Write-Host "Run 'Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe' in an admin powershell prompt to install winget." -Foreground Red
}
# Check that python is installed
if (-not (Get-Command "python" -ErrorAction SilentlyContinue)) {
Write-Host "Error: python is not installed." -Foreground Red
if ($winget) {
Write-Host "Attempting to install python."
winget install --id=Python.Python.3.11 -e
}
else {
Write-Host "Please install python to continue." -Foreground Red
exit 1
}
}
# Check that java is installed
if (-not (Get-Command "java" -ErrorAction SilentlyContinue)) {
Write-Host "Error: java is not installed." -Foreground Red
if ($winget) {
Write-Host "Attempting to install java."
winget install AdoptOpenJDK.OpenJDK.11
}
else {
Write-Host "Please install java to continue." -Foreground Red
exit 1
}
}
if (Test-Path ".venv") { } else { python -m venv .venv }
.venv\Scripts\Activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python .\client.py

3
client/client.py Normal file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env python3
DOWNLOADER_URL = "https://github.com/North-West-Wind/CurseForge-CLI/releases/latest/download/curseforge.zip"

22
client/client.sh Normal file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
# check that python is installed
if ! [ -x "$(command -v python)" ]; then
echo 'Error: python is not installed. Please install it to continue.' >&2
exit 1
fi
# check that java is installed
if ! [ -x "$(command -v java)" ]; then
echo 'Error: java is not installed. Please install it to continue.' >&2
exit 1
fi
if [ -d .venv ]; then; else python -m venv .venv; fi
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python ./client.py

5
client/requirements.txt Normal file
View File

@@ -0,0 +1,5 @@
certifi==2023.5.7
charset-normalizer==3.1.0
idna==3.4
requests==2.31.0
urllib3==2.0.3

194
modpack/manifest.json Normal file
View File

@@ -0,0 +1,194 @@
{
"minecraft": {
"version": "1.16.5",
"modLoaders": [
{
"id": "forge-36.2.34",
"primary": true
}
]
},
"manifestType": "minecraftModpack",
"overrides": "overrides",
"manifestVersion": 1,
"version": "0.1.0",
"author": "Liightninggod",
"name": "FishPog Pixelmon",
"files": [
{
"projectID": 32274,
"fileID": 4012858,
"required": true,
"__meta": {
"name": "JourneyMap"
}
},
{
"projectID": 223852,
"fileID": 3776277,
"required": true,
"__meta": {
"name": "Storage Drawers"
}
},
{
"projectID": 233342,
"fileID": 3216206,
"required": true,
"__meta": {
"name": "Fairy Lights"
}
},
{
"projectID": 235279,
"fileID": 3376782,
"required": true,
"__meta": {
"name": "Chisel",
"dependencies": [
267602
]
}
},
{
"projectID": 237307,
"fileID": 3738137,
"required": true,
"__meta": {
"name": "Cosmetic Armor Reworked"
}
},
{
"projectID": 238222,
"fileID": 4371666,
"required": true,
"__meta": {
"name": "Just Enough Items (JEI)"
}
},
{
"projectID": 247560,
"fileID": 4024011,
"required": true,
"__meta": {
"name": "Oh The Biomes You'll Go"
}
},
{
"projectID": 252848,
"fileID": 3382150,
"required": true,
"__meta": {
"name": "Nature's Compass"
}
},
{
"projectID": 267602,
"fileID": 3137659,
"required": true,
"__meta": {
"name": "ConnectedTexturesMod"
}
},
{
"projectID": 268495,
"fileID": 3863227,
"required": true,
"__meta": {
"name": "Simple Storage Network"
}
},
{
"projectID": 328085,
"fileID": 3536025,
"required": true,
"__meta": {
"name": "Create",
"dependencies": [
486392
]
}
},
{
"projectID": 361385,
"fileID": 3276350,
"required": true,
"__meta": {
"name": "Pam's HarvestCraft 2 - Crops"
}
},
{
"projectID": 365460,
"fileID": 3281234,
"required": true,
"__meta": {
"name": "Pam's HarvestCraft 2 - Trees"
}
},
{
"projectID": 372534,
"fileID": 3190867,
"required": true,
"__meta": {
"name": "Pam's HarvestCraft 2 - Food Core"
}
},
{
"projectID": 389487,
"fileID": 4564388,
"required": true,
"__meta": {
"name": "Pixelmon"
}
},
{
"projectID": 402231,
"fileID": 3418627,
"required": true,
"__meta": {
"name": "Pam's HarvestCraft 2 - Food Extended",
"dependencies": [
372534
]
}
},
{
"projectID": 486392,
"fileID": 3535459,
"required": true,
"__meta": {
"name": "Flywheel"
}
},
{
"projectID": 509285,
"fileID": 3503936,
"required": true,
"__meta": {
"name": "Create Deco",
"dependencies": [
328085
]
}
},
{
"projectID": 535563,
"fileID": 3882536,
"required": true,
"__meta": {
"name": "Create gear addon",
"dependencies": [
328085
]
}
},
{
"projectID": 818696,
"fileID": 4369234,
"required": true,
"__meta": {
"name": "PokeFactory Compatibility"
}
}
]
}

View File

6
pyproject.toml Normal file
View File

@@ -0,0 +1,6 @@
[tool.isort]
profile = "black"
[tool.black]
line-length = 119
target-version = ['py311']

5
requirements.txt Normal file
View File

@@ -0,0 +1,5 @@
certifi==2023.5.7
charset-normalizer==3.1.0
idna==3.4
requests==2.31.0
urllib3==2.0.3

95
tooling.py Normal file
View File

@@ -0,0 +1,95 @@
#!/usr/bin/env python3
import os, sys, argparse, tempfile, subprocess, shutil, requests
parser = argparse.ArgumentParser(description="a helper script for liightninggod modpacks")
parser.add_argument("--export", "-e", help="export modpack zip", action="store_true")
parser.add_argument("--setup", "-s", help="setup project and install dependencies", action="store_true")
parser.add_argument("--force", "-f", help="forces things when needed, like redoing setup", action="store_true")
parser.add_argument("--build-pax", help="builds pax from source, even if on a supported platform", action="store_true")
args = parser.parse_args()
WORKING_DIR = os.getcwd()
PAX_GITHUB = "https://github.com/froehlichA/pax"
PAX_LATEST_RELEASE = f"{PAX_GITHUB}/releases/latest/download"
PAX_LINUX = f"{PAX_LATEST_RELEASE}/pax"
PAX_WINDOWS = f"{PAX_LATEST_RELEASE}/pax-windows.zip"
OS = sys.platform
def __main__():
if args.setup:
print("setting up pack")
setup_pack()
return
elif args.export:
print("exporting modpack")
return
print(
"no command provided. pass the -h flag to see commands for pack, or run ./pax to interact with the modpack's files"
)
def setup_pack():
pax()
# pax
def pax():
if os.path.isfile(os.path.join(WORKING_DIR, "pax")) and not args.force:
print("pax is already installed")
return
if OS == "darwin" or args.build_pax:
print("building pax from source...")
pax_from_source()
print("pax built successfully")
return
if OS == "linux":
print("downloading pax binary for linux...")
r = requests.get(PAX_LINUX, allow_redirects=True)
open("pax", "wb").write(r.content)
os.chmod("pax", 0o755)
return
if OS == "windows":
print("downloading and extracting pax for windows...")
r = requests.get(PAX_WINDOWS, allow_redirects=True)
open("pax-windows.zip", "wb").write(r.content)
shutil.unpack_archive("pax-windows.zip", ".")
os.remove("pax-windows.zip")
return
def pax_from_source():
if OS == "windows":
print("building from source not supported on windows yet")
os._exit(1)
if not command_exists("nimble"):
print("nim is not installed - make sure it is installed for your platform")
os._exit(1)
TMP = tempfile.mkdtemp()
os.chdir(TMP)
subprocess.run(["git", "clone", PAX_GITHUB], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
os.chdir("pax")
subprocess.run(["nimble", "build", "-d:release"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
subprocess.run(["cp", "./pax", WORKING_DIR])
# helper functions
def command_exists(binary_name):
return shutil.which(binary_name) is not None
# entry
__main__()

18
venv.ps1 Normal file
View File

@@ -0,0 +1,18 @@
# Check for python3 or python
if (Get-Command "python3") {
$python = "python3"
} else {
$python = "python"
}
# Check if .venv directory exists
if (-Not (Test-Path "./.venv")) {
& $python -m venv .venv
}
# Activate the virtual environment
. ./.venv/bin/Activate.ps1
# Install required packages
& $python -m pip install --upgrade pip
& $python -m pip install -r requirements.txt

15
venv.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
if command -v python3 &> /dev/null; then
python="python3"
else
python="python"
fi
if [ -d .venv ]; then exit 0; fi
$python -m venv .venv
source .venv/bin/activate
$python -m pip install --upgrade pip
$python -m pip install -r requirements.txt