-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8031280
Showing
6 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
out/* | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import os | ||
import zipfile | ||
import pathlib | ||
|
||
loader: str = "0.14.19" | ||
lwjgl3: str = "3.1.6" | ||
lwjgl2: str = "2.9.4-nightly-20150209" | ||
|
||
|
||
def mkdir_if_not_exists(path: str): | ||
if not os.path.exists(path): | ||
os.mkdir(path) | ||
|
||
|
||
class Generator: | ||
def __init__(self, loader_version: str, minecraft_version: str, lwjgl_version: str, path: str = "temp"): | ||
self.lwjgl_version: str = lwjgl_version | ||
self.minecraft_version: str = minecraft_version | ||
self.loader_version: str = loader_version | ||
self.path: str = path | ||
|
||
def process(self, subject: str) -> str: | ||
subject = subject.replace("${loader_version}", self.loader_version) | ||
subject = subject.replace("${minecraft_version}", self.minecraft_version) | ||
subject = subject.replace("${lwjgl_version}", self.lwjgl_version) | ||
subject = subject.replace("${lwjgl_name}", | ||
"LWJGL 3" if self.lwjgl_version.startswith( | ||
"3") else "LWJGL 2") | ||
subject = subject.replace("${lwjgl_uid}", | ||
"org.lwjgl3" if self.lwjgl_version.startswith( | ||
"3") else "org.lwjgl") | ||
return subject | ||
|
||
def prepare_skeleton(self): | ||
mkdir_if_not_exists("temp") | ||
|
||
with open("skel/mmc-pack.json", "r") as f: | ||
with open("temp/mmc-pack.json", "w") as t: | ||
t.write(self.process(f.read())) | ||
|
||
with open("skel/instance.cfg", "r") as f: | ||
with open("temp/instance.cfg", "w") as t: | ||
t.write(self.process(f.read())) | ||
|
||
mkdir_if_not_exists("temp/patches") | ||
with open("skel/patches/net.fabricmc.intermediary.json", "r") as f: | ||
with open("temp/patches/net.fabricmc.intermediary.json", "w") as t: | ||
t.write(self.process(f.read())) | ||
|
||
with open("skel/legacyfabric.png", "rb") as f: | ||
with open("temp/legacyfabric.png", "wb") as t: | ||
t.write(f.read()) | ||
|
||
def create_zip(self): | ||
with zipfile.ZipFile(f"out/legacyfabric-{self.minecraft_version}+loader.{self.loader_version}.zip", "w") as z: | ||
z.write("temp/mmc-pack.json", "mmc-pack.json") | ||
z.write("temp/instance.cfg", "instance.cfg") | ||
z.write("temp/patches/net.fabricmc.intermediary.json", | ||
"patches/net.fabricmc.intermediary.json") | ||
z.write("temp/legacyfabric.png", "legacyfabric.png") | ||
|
||
self.cleanup() | ||
|
||
def cleanup(self): | ||
for root, dirs, files in os.walk(self.path, topdown=False): | ||
for file in files: | ||
os.remove(os.path.join(root, file)) | ||
for dir in dirs: | ||
os.rmdir(os.path.join(root, dir)) | ||
|
||
os.rmdir(self.path) | ||
|
||
|
||
versions = [ | ||
("1.13.2", 3), | ||
("1.12.2", 2), | ||
("1.11.2", 2), | ||
("1.10.2", 2), | ||
("1.9.4", 2), | ||
("1.8.9", 2), | ||
("1.7.10", 2), | ||
("1.6.4", 2), | ||
("1.5.2", 2), | ||
("1.4.7", 2), | ||
("1.3.2", 2), | ||
] | ||
|
||
print(f"target loader: {loader}") | ||
mkdir_if_not_exists("out") | ||
for version, lwjgl in versions: | ||
lwjgl_version = lwjgl3 if lwjgl == 3 else lwjgl2 | ||
print(f"generating {version} with LWJGL {lwjgl_version}...") | ||
g = Generator(loader, version, lwjgl_version) | ||
g.prepare_skeleton() | ||
g.create_zip() | ||
|
||
# g = Generator(loader, "1.13.2", lwjgl3) | ||
# g.prepare_skeleton() | ||
# g.create_zip() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
iconKey=legacyfabric | ||
name=LegacyFabric ${minecraft_version} | ||
InstanceType=OneSix | ||
MCLaunchMethod=LauncherPart |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"components": [ | ||
{ | ||
"cachedName": "${lwjgl_name}", | ||
"cachedVersion": "${lwjgl_version}", | ||
"cachedVolatile": true, | ||
"dependencyOnly": true, | ||
"uid": "${lwjgl_uid}", | ||
"version": "${lwjgl_version}" | ||
}, | ||
{ | ||
"cachedName": "Minecraft", | ||
"cachedRequires": [ | ||
{ | ||
"equals": "${lwjgl_version}", | ||
"suggests": "${lwjgl_version}", | ||
"uid": "${lwjgl_uid}" | ||
} | ||
], | ||
"cachedVersion": "${minecraft_version}", | ||
"important": true, | ||
"uid": "net.minecraft", | ||
"version": "${minecraft_version}" | ||
}, | ||
{ | ||
"cachedName": "Intermediary Mappings", | ||
"cachedRequires": [ | ||
{ | ||
"equals": "${minecraft_version}", | ||
"uid": "net.minecraft" | ||
} | ||
], | ||
"cachedVersion": "${minecraft_version}", | ||
"cachedVolatile": true, | ||
"dependencyOnly": true, | ||
"uid": "net.fabricmc.intermediary", | ||
"version": "${minecraft_version}" | ||
}, | ||
{ | ||
"cachedName": "Fabric Loader", | ||
"cachedRequires": [ | ||
{ | ||
"equals": "${minecraft_version}", | ||
"uid": "net.fabricmc.intermediary" | ||
} | ||
], | ||
"cachedVersion": "${loader_version}", | ||
"uid": "net.fabricmc.fabric-loader", | ||
"version": "${loader_version}" | ||
} | ||
], | ||
"formatVersion": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"formatVersion": 1, | ||
"+libraries": [ | ||
{ | ||
"name": "net.legacyfabric:intermediary:${minecraft_version}", | ||
"url": "https://maven.legacyfabric.net/" | ||
} | ||
], | ||
"name": "Intermediary Mappings", | ||
"uid": "net.fabricmc.intermediary", | ||
"version": "${minecraft_version}" | ||
} |