-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
78 lines (58 loc) · 2.22 KB
/
setup.py
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
74
75
76
77
import sys
import shutil
import os
import json
from print_color import printc
path = sys.argv[1]
def setup():
if not os.path.isdir(path):
printc("please input a valid directory as an argument","ERROR")
print("e.g. python setup.py /Users/admin/Library/Application Support/minecraft")
exit()
printc("ARM64 Native Minecraft Setup Script - For Apple Sillicon MacBooks","HEADER")
if(input("Proceed?(y/n) ") != "y"):
exit()
if not os.path.exists(path+"/lwjglnatives"):
shutil.copytree("./lwjglnatives",path+"/lwjglnatives")
shutil.copy("./lwjglfat.jar",path+"/libraries/lwjglfat.jar")
def select():
versions = []
for i,j in enumerate([ name for name in os.listdir(path+"/versions") if os.path.isdir(os.path.join(path+"/versions", name)) ]):
versions.append(j)
printc(str(i)+". ","OKGREEN","")
print(j)
ver = int(input("Please select the version to modify:"))
if(ver > len(versions)):
printc("Please enter a valid number","ERROR")
exit()
if(input(f"Selected {versions[ver]}, proceed?(y/n) ") != "y"):
exit()
newpath = path+"/versions/"+versions[ver]+"-arm/"
shutil.copytree(path+"/versions/"+versions[ver], newpath)
os.rename(newpath+versions[ver]+".jar",newpath+versions[ver]+"-arm.jar")
os.rename(newpath+versions[ver]+".json",newpath+versions[ver]+"-arm.json")
modify(newpath+versions[ver]+"-arm.json",versions[ver]+"-arm")
# Modify JSON
def modify(path,ver):
jvm_args = ["${natives_directory}/../../libraries/lwjglfat.jar:${classpath}",
"-Dorg.lwjgl.librarypath=${natives_directory}/../../lwjglnatives/",
"-Dfml.earlyprogresswindow=false"]
f = open(path)
data = json.load(f)
data["id"] = ver
data["arguments"]["jvm"].pop()
data["arguments"]["jvm"].extend(jvm_args)
new_lib = []
for item in data["libraries"]:
if("lwjgl" not in item["downloads"]["artifact"]["url"]):
new_lib.append(item)
data["libraries"] = new_lib
with open(path, 'w') as f:
json.dump(data, f)
if __name__ == "__main__":
try:
setup()
select()
printc("Successful!","OKGREEN")
except:
printc("Error Occured.","ERROR")