Add stage to fix legacy assets

This commit is contained in:
Fierelier 2022-05-14 00:51:47 +02:00
parent 835f94dd47
commit a02b181b6a
4 changed files with 75 additions and 44 deletions

View File

@ -0,0 +1,30 @@
with open(p(assetsPath,"indexes",launcherVariables["assets_index_name"] + ".json"),"r") as fileh: assetJson = json.loads(fileh.read())
legacyAssetType = False
if "map_to_resources" in assetJson and assetJson["map_to_resources"] == True:
legacyAssetType = "map_to_resources"
elif "virtual" in assetJson and assetJson["virtual"] == True:
legacyAssetType = "virtual"
if legacyAssetType != False:
print(colored(colorama.Fore.GREEN,"\nCopying legacy assets..."))
for asset in assetJson["objects"]:
hash = assetJson["objects"][asset]["hash"]
assetIn = p(assetsPath,"objects",hash[:2],hash)
assetOut = False
if legacyAssetType == "map_to_resources":
assetOut = p(launcherVariables["game_directory"],"resources",asset.replace("/",os.path.sep))
if legacyAssetType == "virtual":
assetOut = p(assetsPath,"virtual",launcherVariables["assets_index_name"],asset.replace("/",os.path.sep))
try:
os.makedirs(pUp(assetOut))
except:
pass
if (not os.path.isfile(assetOut)) and os.path.isfile(assetIn):
shutil.copyfile(assetIn,assetOut)
if legacyAssetType == "virtual":
launcherVariables["assets_root"] = p(launcherVariables["assets_root"],"virtual",launcherVariables["assets_index_name"])
launcherVariables["game_assets"] = launcherVariables["assets_root"]

View File

@ -0,0 +1,41 @@
# JVM arguments:
args = []
if not findArgument(jvmArguments,"-Djava-library.path="):
args.append("-Djava.library.path=" +nativesOutPath)
if not findArgument(jvmArguments,"-Dminecraft.launcher.brand="):
args.append("-Dminecraft.launcher.brand=" +launcherVariables["launcher_name"])
if not findArgument(jvmArguments,"-Dminecraft.launcher.version="):
args.append("-Dminecraft.launcher.version=" +launcherVariables["launcher_version"])
if lv["osName"] == "windows":
if not findArgument(jvmArguments,"-XX:HeapDumpPath="):
args.append("-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump")
args.append("-Dminecraft.client.jar=" +clientJar)
if not findArgument(jvmArguments,"-cp"):
args.append("-cp")
args.append(libraryList)
for arg in jvmArguments:
for var in launcherVariables:
arg = arg.replace("${" +var+ "}",launcherVariables[var])
args.append(arg)
args = args + json.loads(lv["jvmArguments"])
args.append(clientJson["mainClass"])
for arg in arguments:
for var in launcherVariables:
arg = arg.replace("${" +var+ "}",launcherVariables[var])
args.append(arg)
if not findArgument(args,"--gameDir"):
args.append("--gameDir")
args.append(launcherVariables["game_directory"])
if not findArgument(args,"--assetsDir"):
args.append("--assetsDir")
args.append(launcherVariables["assets_root"])

View File

@ -3,6 +3,7 @@ launcherVariables["auth_player_name"] = lv["name"]
launcherVariables["version_name"] = findInChainDeepest(versionsPath,lv["version"],["id"])
launcherVariables["game_directory"] = lv["gamePath"]
launcherVariables["assets_root"] = assetsPath
launcherVariables["game_assets"] = launcherVariables["assets_root"]
launcherVariables["auth_access_token"] = "-"
launcherVariables["auth_uuid"] = hashlib.md5(lv["name"].encode('utf-8')).hexdigest()
launcherVariables["user_type"] = "offline"
@ -11,7 +12,6 @@ launcherVariables["natives_directory"] = nativesOutPath
launcherVariables["launcher_name"] = "offline-minecraft-launcher"
launcherVariables["launcher_version"] = "0.0"
launcherVariables["classpath"] = libraryList
launcherVariables["game_assets"] = assetsPath
launcherVariables["auth_session"] = "-"
launcherVariables["user_properties"] = "{}"
@ -24,46 +24,4 @@ if lv["profileFolder"] == "1":
if launcherVariables["game_directory"].replace(pUp(launcherVariables["game_directory"]) + os.sep,"",1) == ".minecraft":
print(colored(colorama.Fore.MAGENTA,"> game_directory is called .minecraft, setting APPDATA/HOME environment variables to parent directory."))
os.environ["APPDATA"] = pUp(launcherVariables["game_directory"])
os.environ["HOME"] = os.environ["APPDATA"]
# JVM arguments:
args = []
if not findArgument(jvmArguments,"-Djava-library.path="):
args.append("-Djava.library.path=" +nativesOutPath)
if not findArgument(jvmArguments,"-Dminecraft.launcher.brand="):
args.append("-Dminecraft.launcher.brand=" +launcherVariables["launcher_name"])
if not findArgument(jvmArguments,"-Dminecraft.launcher.version="):
args.append("-Dminecraft.launcher.version=" +launcherVariables["launcher_version"])
if lv["osName"] == "windows":
if not findArgument(jvmArguments,"-XX:HeapDumpPath="):
args.append("-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump")
args.append("-Dminecraft.client.jar=" +clientJar)
if not findArgument(jvmArguments,"-cp"):
args.append("-cp")
args.append(libraryList)
for arg in jvmArguments:
for var in launcherVariables:
arg = arg.replace("${" +var+ "}",launcherVariables[var])
args.append(arg)
args = args + json.loads(lv["jvmArguments"])
args.append(clientJson["mainClass"])
for arg in arguments:
for var in launcherVariables:
arg = arg.replace("${" +var+ "}",launcherVariables[var])
args.append(arg)
if not findArgument(args,"--gameDir"):
args.append("--gameDir")
args.append(launcherVariables["game_directory"])
if not findArgument(args,"--assetsDir"):
args.append("--assetsDir")
args.append(launcherVariables["assets_root"])
os.environ["HOME"] = os.environ["APPDATA"]

View File

@ -8,4 +8,6 @@ downloadonly-quit.py
libraries-setup.py
natives-extract.py
launcher-variables.py
assets-legacy.py
jvm-arguments.py
launch.py