Skip to content

Commit

Permalink
Prepare Update (#112)
Browse files Browse the repository at this point in the history
* Add a script to automatically update mods

* Update mods:
- Xaero's Minimap: 23.8.0 -> 23.8.4
- Xaero's World Map: 1.34.1 -> 1.35.0
- censoredASM: 5.16 -> 5.17
- Mixinbooter: 8.4 -> 8.6
- CEu: 2.7.3 -> 2.7.4
- AE2 UEL: 0.55.23b -> 0.55.24

* always add all ae2 recipes, and add a tooltip instead

* Update mods:
- GregTech CE Unofficial 2.7.4-beta -> 2.8.1-beta
- GroovyScript 0.6.4 -> 0.7.0
- VisualOres 0.2.2 -> 0.2.4

- Had Enough Items 4.25.0 -> 4.25.1
- Xaero's Minimap 23.8.3 -> 23.9.0
- Xaero's World Map 1.35.0 -> 1.37.0
- CensoredASM 5.17 -> 5.18
- MixinBooter 8.6 -> 8.9
- LittleTiles v1.5.82 -> v1.5.84
- AE2 Unofficial Extended Life v0.55.24 -> v0.55.27
- AE2 Fluid Crafting Rework 2.4.31-r -> 2.4.33-r
- Sledgehammer 2.0.23 -> 2.0.25

* downgrade Xaero's mods due to instability
- Xaero's Minimap 23.9.0 -> 23.8.4
- Xaero's World Map 1.37.0 -> 1.36.0

* move gt cfg to new location

* revert ae2 script changes

* mod updates

xaero's minimap -> v23.9.1
xaero's worldmap -> v1.37.1
mixinbooter -> v8.8
littletiles -> v1.5.85
gtceu -> v2.8.3
sledgehammer -> v2.0.25
groovyscript -> v0.7.1

removes MTLib

---------

Co-authored-by: TechLord22 <37029404+techlord22@users.noreply.github.com>
  • Loading branch information
htmlcsjs and TechLord22 authored Dec 12, 2023
1 parent b460b04 commit 6ff73fb
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 76 deletions.
127 changes: 73 additions & 54 deletions build/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,41 @@

def parse_args():
parser = argparse.ArgumentParser(prog="build", description=__doc__)
parser.add_argument("--sha", action="store_true", help="append git hash to zips")
parser.add_argument("--sha", action="store_true",
help="append git hash to zips")
parser.add_argument("--name", type=str, help="append name to zips")
parser.add_argument("--retries", type=int, default=3, help="download attempts before failure")
parser.add_argument("--clean", action="store_true", help="clean output dirs")
parser.add_argument("--retries", type=int, default=3,
help="download attempts before failure")
parser.add_argument("--clean", action="store_true",
help="clean output dirs")
parser.add_argument("--dev_build", action="store_true",
help="makes a folder with all the files symlinked for development. probally only works on linux")
parser.add_argument("-c", "--client", action="store_true",
help="only builds the client pack")
return parser.parse_args()


def build(args):
modlist = []
basePath = os.path.normpath(os.path.realpath(__file__)[:-7] + "..")
copyDirs = ["/groovy", "/config", "/mods", "/structures"]
serverCopyDirs = ["/groovy", "/config", "/mods", "/structures"]
copyDirs = ["/config", "/mods", "/groovy"]
serverCopyDirs = ["/config", "/mods", "/groovy"]
modURLlist = []
modClientOnly = []
# remove the old build files

shutil.rmtree(basePath + "/buildOut/client/overrides",
ignore_errors=True)
shutil.rmtree(basePath + "/buildOut/server", ignore_errors=True)

if args.clean:
shutil.rmtree(basePath + "/buildOut/client/overrides", ignore_errors=True)
shutil.rmtree(basePath + "/buildOut/server", ignore_errors=True)
shutil.rmtree(basePath + "/mods", ignore_errors=True)
sys.exit(0)
sha = ""
if args.sha:
try:
p = subprocess.run(["git", "rev-parse", "--short", "HEAD"], capture_output=True, cwd=basePath)
p = subprocess.run(
["git", "rev-parse", "--short", "HEAD"], capture_output=True, cwd=basePath)
sha = p.stdout.strip().decode("utf-8")
except Exception as e:
print("could not determine git sha, skipping")
Expand Down Expand Up @@ -78,54 +88,58 @@ def mkdirs(path):

r = requests.get(mod["url"])

hash = hashlib.sha256(jar.read()).hexdigest()
hash = hashlib.sha256(r.content).hexdigest()
if str(hash) == mod["hash"]:
jar.write(r.content)
modlist.append(mod["name"])
print("hash succsessful")
print("hash succsessful for {}".format(mod["name"]))
break
else:
print("hash unsuccsessful")
print("hash unsuccsessful for {}".format(mod["name"]))
print("use", str(hash), "this if it is consistant across runs")
pass

for dir in copyDirs:
try:
shutil.copytree(basePath + dir, basePath + "/buildOut/client/overrides" + dir)
shutil.copytree(basePath + dir, basePath +
"/buildOut/client/overrides" + dir)
except Exception as e:
print("Directory exists, skipping")

print("directories copied to buildOut/client")
archive = "buildOut/client"
if sha:
archive = "%s-%s" % (archive, sha)
shutil.copy(basePath + "/manifest.json", basePath + "/buildOut/client/manifest.json")
shutil.copy(basePath + "/manifest.json", basePath +
"/buildOut/client/manifest.json")
shutil.make_archive(archive, "zip", basePath + "/buildOut/client")
print('client zip "%s.zip" made' % (archive))

if (args.client):
return

cringe = []
headers = {'Accept': 'application/json', 'x-api-key': os.getenv("CFAPIKEY")}
headers = {'Accept': 'application/json',
'x-api-key': os.getenv("CFAPIKEY")}
for mod in manifest["files"]:
clientOnly = False
try:
clientOnly = mod["clientOnly"]
# clean up the distributed file
del mod["clientOnly"]
except:
pass
modClientOnly.append(clientOnly)

r = requests.get(
'https://api.curseforge.com/v1/mods/{0}/files/{1}/download-url'.format(mod["projectID"], mod["fileID"]),
'https://api.curseforge.com/v1/mods/{0}/files/{1}/download-url'.format(
mod["projectID"], mod["fileID"]),
headers=headers)
try:
metadata = json.loads(r.text)
except:
print(
'https://api.curseforge.com/v1/mods/{0}/files/{1}/download-url'.format(mod["projectID"], mod["fileID"]))
cringe_r = requests.get('https://api.curseforge.com/v1/mods/{0}'.format(mod["projectID"]), headers=headers)
cringe_r = requests.get(
'https://api.curseforge.com/v1/mods/{0}'.format(mod["projectID"]), headers=headers)
try:
data = cringe_r.json()["data"]
cringe.append("https://www.curseforge.com/minecraft/mc-mods/{0}/files/{1}".format(data["slug"], mod["fileID"]))
cringe.append(
"https://www.curseforge.com/minecraft/mc-mods/{0}/files/{1}".format(data["slug"], mod["fileID"]))
except:
cringe.append('This is the raw mod id and file id, the cf api was being mega fucked: `{0}`, `{1}`'.format(mod["projectID"], mod["fileID"]))
cringe.append('This is the raw mod id and file id, the cf api was being odd: `{0}`, `{1}`'.format(
mod["projectID"], mod["fileID"]))

continue

Expand All @@ -136,33 +150,35 @@ def mkdirs(path):
modlist.append(name)
else:
modlist.append(metadata["data"].split("/")[-1])
modURLlist.append(metadata["data"])

# write the json without "clientOnly" to the file
with open(basePath + "/manifest.json", mode='w') as file:
json.dump(manifest, file, indent=4);

modURLlist.append(metadata["data"])
try:
modClientOnly.append(mod["clientOnly"])
except:
modClientOnly.append(False)
print("modlist compiled")

with open(basePath + "/buildOut/modlist.html", "w") as file:
data = "<html><body><h1>Modlist</h1><ul>"
for mod in modlist:
data += "<li>" + mod.split(".jar")[0] + "</li>"
data += "</ul></body></html>"
file.write(data)
print("modlist.html done")
shutil.copy(basePath + "/manifest.json", basePath + "/buildOut/server/manifest.json")
shutil.copy(basePath + "/manifest.json", basePath +
"/buildOut/server/manifest.json")
shutil.copy(basePath + "/LICENSE", basePath + "/buildOut/server/LICENSE")
shutil.copy(basePath + "/launch.sh", basePath + "/buildOut/server/launch.sh")
shutil.copy(basePath + "/launch.sh", basePath +
"/buildOut/server/launch.sh")
for dir in serverCopyDirs:
try:
shutil.copytree(basePath + dir, basePath + "/buildOut/server" + dir)
shutil.copytree(basePath + dir, basePath +
"/buildOut/server" + dir)
except Exception as e:
print("Directory exists, skipping")
print("directories copied to buildOut/server")
for i, mod in enumerate(modURLlist):
jarname = mod.split("/")[-1]
if (modClientOnly[i]):
if (modClientOnly[i] == True):
continue

if os.path.exists(os.path.join(cachepath, jarname)):
Expand All @@ -180,15 +196,15 @@ def mkdirs(path):
forgeVer = manifest["minecraft"]["modLoaders"][0]["id"].split("-")[-1]
mcVer = manifest["minecraft"]["version"]
url = (
"https://maven.minecraftforge.net/net/minecraftforge/forge/"
+ mcVer
+ "-"
+ forgeVer
+ "/forge-"
+ mcVer
+ "-"
+ forgeVer
+ "-installer.jar"
"https://maven.minecraftforge.net/net/minecraftforge/forge/"
+ mcVer
+ "-"
+ forgeVer
+ "/forge-"
+ mcVer
+ "-"
+ forgeVer
+ "-installer.jar"
)
r = requests.get(url)
jar.write(r.content)
Expand All @@ -201,7 +217,8 @@ def mkdirs(path):
r = requests.get(url)
jar.write(r.content)
print("Vanilla Downloaded")
subprocess.run(["java", "-jar", "forge-installer.jar", "--installServer"], cwd=basePath + "/buildOut/server/")
subprocess.run(["java", "-jar", "forge-installer.jar",
"--installServer"], cwd=basePath + "/buildOut/server/")
print("Forge Installed")
if len(cringe) != 0 or os.path.exists(basePath + "/README_SERVER.md"):
with open(basePath + "/buildOut/server/README_SERVER.md", "w") as f:
Expand Down Expand Up @@ -232,28 +249,30 @@ def mkdirs(path):
shutil.rmtree(basePath + "/buildOut/mmc/minecraft/mods/")
except:
pass
shutil.copytree(basePath + "/buildOut/server/mods/", basePath + "/buildOut/mmc/minecraft/mods/")
shutil.copytree(basePath + "/buildOut/server/mods/",
basePath + "/buildOut/mmc/minecraft/mods/")
for dir in copyDirs:
try:
os.symlink(basePath + dir, basePath + "/buildOut/mmc/minecraft/" + dir)
os.copytree(basePath + dir, basePath +
"/buildOut/mmc/minecraft/" + dir)
except Exception as e:
print("Directory exists, skipping")
print("directories copied to buildOut/mmc/minecraft")

for i, mod in enumerate(modURLlist):
jarname = mod.split("/")[-1]
if (not modClientOnly[i]):
break

with open(basePath + "/buildOut/mmc/minecraft/mods/" + jarname, "w+b") as jar:
r = requests.get(mod)
jar.write(r.content)
print(mod + " Downloaded")

shutil.copy(basePath + "/mmc-instance-data.json", basePath + "/buildOut/mmc/mmc-pack.json")
shutil.copy(basePath + "/mmc-instance-data.json",
basePath + "/buildOut/mmc/mmc-pack.json")
instanceFolder = input("What is your MultiMC instance folder:")
instanceName = input("What do you want to call the instance:")
os.symlink(basePath + "/buildOut/mmc/", instanceFolder + "/" + instanceName)
os.symlink(basePath + "/buildOut/mmc/",
instanceFolder + "/" + instanceName)
print("you might need to add an instance.cfg for mmc to reconise it")
print("done")

Expand Down
37 changes: 37 additions & 0 deletions build/updateMods.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import os
import json
import requests
from datetime import datetime

def is112(file):
True in ["1.12" in i for i in file["gameVersions"]]

headers = {
"Accept": "application/json",
"x-api-key": os.getenv("CFAPIKEY")
}

basePath = os.path.normpath(os.path.realpath(__file__)[:-13] + "..")
with open(f"{basePath}/manifest.json") as f:
manifest = json.load(f)

ver_id = requests.get("https://api.curseforge.com/v1/minecraft/version/1.12.2", headers = headers).json()["data"]["gameVersionTypeId"]

for entry in manifest["files"]:
project_id = entry["projectID"]
mod = requests.get(f"https://api.curseforge.com/v1/mods/{project_id}", headers = headers).json()["data"]

old_file = requests.get(f"https://api.curseforge.com/v1/mods/{project_id}/files/" + str(entry["fileID"]), headers = headers).json()["data"]

latest_files = requests.get(f"https://api.curseforge.com/v1/mods/{project_id}/files?gameVersionTypeId={ver_id}", headers = headers).json()["data"]
new_file = sorted(latest_files, key=lambda file: datetime.fromisoformat(file["fileDate"]))

new_file = new_file[-1]

if datetime.fromisoformat(new_file["fileDate"]) > datetime.fromisoformat(old_file["fileDate"]):
if input(mod["name"] + " (" + old_file["fileName"] + ") -> " + new_file["fileName"] + "?") == "y":
entry["fileID"] = new_file["id"]


with open(f"{basePath}/manifest.json", "w") as f:
json.dump(manifest, f, indent=4)
Loading

0 comments on commit 6ff73fb

Please sign in to comment.