From bc164665853ef447a79d14027b327679db279c00 Mon Sep 17 00:00:00 2001 From: Fierelier Date: Wed, 16 Jun 2021 12:55:30 +0200 Subject: [PATCH] Add support for dumb natives --- offline-minecraft-launcher.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/offline-minecraft-launcher.py b/offline-minecraft-launcher.py index 4874ce7..a600fb7 100644 --- a/offline-minecraft-launcher.py +++ b/offline-minecraft-launcher.py @@ -173,6 +173,9 @@ def processVersion(versionsPath,libraryPath,nativePath,version): if lv["osName"] == "macos" and native == False and "natives-osx" in library["downloads"]["classifiers"]: native = library["downloads"]["classifiers"]["natives-osx"] + + if native == False: + continue elif "name" in library: # Dumb libraries if not "url" in library: library["url"] = "https://libraries.minecraft.net" @@ -180,7 +183,24 @@ def processVersion(versionsPath,libraryPath,nativePath,version): while len(l["url"]) > 0 and l["url"][-1] == "/": l["url"] = l["url"][:-1] l["url"] = l["url"] + "/" + l["filePath"] - l["filePathOS"] = p(libraryPath,l["filePath"].replace("/",os.path.sep)) + if "natives" in library: + input(library) + l["type"] = "native" + if lv["osName"] in library["natives"]: + native = library["natives"][lv["osName"]] + + if lv["osName"] == "macos" and native == False and "osx" in library["natives"]: + native = library["natives"]["osx"] + + if native == False: + continue + + l["filePath"] = l["filePath"][:-4] + "-" + native + ".jar" + l["url"] = l["url"][:-4] + "-" + native + ".jar" + l["filePathOS"] = p(nativePath,l["filePath"].replace("/",os.path.sep)) + #input(l) + else: + l["filePathOS"] = p(libraryPath,l["filePath"].replace("/",os.path.sep)) libraries.append(l) if os.path.isfile(p(versionPath,version + ".jar")): @@ -318,6 +338,9 @@ def main(): for library in libraries: if library["type"] == "native": if "rules" in library and checkRules(library["rules"]) == "disallow": continue + if not os.path.isfile(library["filePathOS"]): + print("Native not found: " +library["path"]+ ":" +library["version"]) + continue proc = subprocess.Popen(["7z","x",library["filePathOS"],"-o" +nativesOutPath,"-aos"],stdout=subprocess.DEVNULL) rtn = proc.wait() if rtn != 0: raise Exception("process","return code isn't 0") @@ -388,7 +411,7 @@ def main(): pkwargs = { "stdout": subprocess.DEVNULL, "stdin": subprocess.DEVNULL, - "stderr": subprocess.DEVNULL, + "stderr": subprocess.DEVNULL } if lv["osName"] == "windows": pkwargs["creationflags"] = 0x00000008 subprocess.Popen([lv["java"] + "w"] + args,**pkwargs)