fix version_mappings_generator.py, generate resources for 21w14a - 17w46a

This commit is contained in:
Bixilon 2021-04-08 17:47:47 +02:00
parent eac5a2ca67
commit 4b36103db1
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
5 changed files with 1324 additions and 50 deletions

View File

@ -57,7 +57,7 @@ public final class Minosoft {
public static final HashSet<EventManager> EVENT_MANAGERS = new HashSet<>();
public static final HashBiMap<Integer, PlayConnection> CONNECTIONS = HashBiMap.create();
private static final CountUpAndDownLatch START_STATUS_LATCH = new CountUpAndDownLatch(1);
private static Configuration config;
public static Configuration config;
private static boolean isExiting;
public static void main(String[] args) {

View File

@ -71,10 +71,12 @@ class MinecraftAssetsManager(
fun generateJarAssets(): String {
val startTime = System.currentTimeMillis()
Log.verbose("Generating client.jar assets for %s...", this.assetVersion.version)
if (verifyAssetHash(this.assetVersion.jarAssetsHash!!)) {
this.assetVersion.jarAssetsHash?.let {
verifyAssetHash(it)
// ToDo: Verify all jar assets
Log.verbose("client.jar assets probably already generated for %s, skipping", this.assetVersion.version)
return this.assetVersion.jarAssetsHash
}
// download jar
downloadAsset(String.format(ProtocolDefinition.MOJANG_LAUNCHER_URL_PACKAGES, this.assetVersion.clientJarHash, "client.jar"), this.assetVersion.clientJarHash!!, true)

View File

@ -16,6 +16,8 @@ package de.bixilon.minosoft.generator;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import de.bixilon.minosoft.Minosoft;
import de.bixilon.minosoft.config.Configuration;
import de.bixilon.minosoft.data.assets.MinecraftAssetsManager;
import de.bixilon.minosoft.data.assets.Resources;
import de.bixilon.minosoft.data.mappings.versions.Version;
@ -24,6 +26,7 @@ import java.io.*;
import java.util.Collections;
public class JarHashGenerator {
private static final String RESOURCE_JSON_PATH = "src/main/resources/assets/minosoft/mapping/resources.json";
public static void main(String[] args) throws IOException {
if (args.length != 1) {
@ -31,9 +34,12 @@ public class JarHashGenerator {
return;
}
try {
Minosoft.config = new Configuration();
Version version = new Version(args[0], -1, -1, Collections.emptyMap(), Collections.emptyMap());
JsonObject json = JsonParser.parseReader(new InputStreamReader(new FileInputStream("src/main/resources/assets/mapping/resources.json"))).getAsJsonObject();
JsonObject json = JsonParser.parseReader(new InputStreamReader(new FileInputStream(RESOURCE_JSON_PATH))).getAsJsonObject();
JsonObject versions = json.getAsJsonObject("versions");
@ -42,7 +48,8 @@ public class JarHashGenerator {
Resources.loadVersion(version, versionJson);
MinecraftAssetsManager assetsManager = new MinecraftAssetsManager(Resources.getAssetVersionByVersion(version), Resources.getPixLyzerDataHashByVersion(version));
var resource = Resources.getAssetVersionByVersion(version);
MinecraftAssetsManager assetsManager = new MinecraftAssetsManager(resource, "dummy");
String jarAssetsHash = assetsManager.generateJarAssets();
versionJson.addProperty("jar_assets_hash", jarAssetsHash);
@ -50,18 +57,17 @@ public class JarHashGenerator {
// reload json, because the generator is async
json = JsonParser.parseReader(new InputStreamReader(new FileInputStream("src/main/resources/assets/mapping/resources.json"))).getAsJsonObject();
json = JsonParser.parseReader(new InputStreamReader(new FileInputStream(RESOURCE_JSON_PATH))).getAsJsonObject();
json.getAsJsonObject("versions").add(version.getVersionName(), versionJson);
File file = new File("src/main/resources/assets/mapping/resources.json");
File file = new File(RESOURCE_JSON_PATH);
FileWriter writer = new FileWriter(file.getAbsoluteFile());
writer.write(new Gson().toJson(json));
writer.close();
System.exit(0);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
throw new RuntimeException(e);
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,6 @@
#
# This software is not affiliated with Mojang AB, the original developer of Minecraft.
import os
import subprocess
import urllib.request
@ -17,49 +16,38 @@ import ujson
print("Minecraft mappings downloader (and generator)")
DOWNLOAD_UNTIL_VERSION = "18w01a"
SKIP_VERSIONS = ["1.13-pre6", "1.13-pre5"]
DATA_FOLDER = "../data/resources/"
TEMP_FOLDER = DATA_FOLDER + "tmp/"
DOWNLOAD_BASE_URL = "https://apimon.de/mcdata/"
RESOURCE_MAPPINGS_INDEX = ujson.load(open("../src/main/resources/assets/mapping/resources.json"))
DOWNLOAD_UNTIL_VERSION = "17w45b"
SKIP_VERSIONS = []
RESOURCE_MAPPINGS_INDEX_PATH = "../src/main/resources/assets/minosoft/mapping/resources.json"
RESOURCE_MAPPINGS_INDEX = ujson.load(open(RESOURCE_MAPPINGS_INDEX_PATH))
VERSION_MANIFEST = ujson.loads(urllib.request.urlopen('https://launchermeta.mojang.com/mc/game/version_manifest.json').read().decode("utf-8"))
VERBOSE_LOG = False
SKIP_COMPILE = False
failedVersionIds = []
partlyFailedVersionIds = []
if not os.path.isdir(DATA_FOLDER):
os.mkdir(DATA_FOLDER)
if not os.path.isdir(TEMP_FOLDER):
os.mkdir(TEMP_FOLDER)
# compile minosoft
def generateJarAssets(versionId):
print("Generating jar asset hash: %s" % versionId)
generateProcess = ""
try:
generateProcess = subprocess.run(r'mvn exec:java -Dexec.mainClass="de.bixilon.minosoft.generator.JarHashGenerator" -Dexec.args="\"%s\""' % versionId, cwd=r'../', shell=True, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# reload mappings
global RESOURCE_MAPPINGS_INDEX
RESOURCE_MAPPINGS_INDEX = ujson.load(open("../src/main/resources/assets/mapping/resources.json"))
except Exception:
print(generateProcess.stdout)
print(generateProcess.stderr)
process = subprocess.Popen(r'mvn exec:java -Dexec.mainClass="de.bixilon.minosoft.generator.JarHashGenerator" -Dexec.args="\"%s\""' % versionId, shell=True, cwd='../', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
exitCode = process.wait()
global RESOURCE_MAPPINGS_INDEX
RESOURCE_MAPPINGS_INDEX = ujson.load(open(RESOURCE_MAPPINGS_INDEX_PATH))
if exitCode != 0:
print(process.stdout.read().decode('utf-8'))
print(process.stderr.read().decode('utf-8'))
print("Compiling minosoft...")
compileProcess = ""
try:
compileProcess = subprocess.run(r'mvn compile', shell=True, check=True, cwd='../', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except Exception:
print(compileProcess.stdout)
print(compileProcess.stderr)
exit(1)
print("Minosoft compiled!")
if not SKIP_COMPILE:
print("Compiling minosoft...")
compileProcess = subprocess.Popen(r'mvn compile', shell=True, cwd='../', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
compileExitCode = compileProcess.wait()
if compileExitCode != 0:
print(compileProcess.stdout.read().decode('utf-8'))
print(compileProcess.stderr.read().decode('utf-8'))
print("Minosoft compiled!")
def downloadVersion(version):
@ -68,8 +56,9 @@ def downloadVersion(version):
print("Force skipping %s" % version["id"])
return
if version["id"] in RESOURCE_MAPPINGS_INDEX["versions"]:
if version["id"] in RESOURCE_MAPPINGS_INDEX["versions"] and "jar_assets_hash" in RESOURCE_MAPPINGS_INDEX["versions"][version["id"]]:
print("Skipping %s" % version["id"])
return
print()
print("DEBUG: Downloading versions json for %s" % version["id"])
@ -81,20 +70,16 @@ def downloadVersion(version):
resourcesVersion["client_jar_hash"] = versionJson["downloads"]["client"]["sha1"]
RESOURCE_MAPPINGS_INDEX["versions"][version["id"]] = resourcesVersion
# dump resources index
with open("../src/main/resources/assets/mapping/resources.json", 'w') as file:
with open(RESOURCE_MAPPINGS_INDEX_PATH, 'w') as file:
ujson.dump(RESOURCE_MAPPINGS_INDEX, file)
# start jar hash generator
try:
generateJarAssets(version["id"])
except Exception:
failedVersionIds.append(version["id"])
print("%s failed!" % version["id"])
return
RESOURCE_MAPPINGS_INDEX["versions"][version["id"]] = resourcesVersion
# dump resources index
with open("../src/main/resources/assets/mapping/resources.json", 'w') as file:
ujson.dump(RESOURCE_MAPPINGS_INDEX, file)
for version in VERSION_MANIFEST["versions"]:
if version["id"] == DOWNLOAD_UNTIL_VERSION: