mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 10:55:01 -04:00
fix version_mappings_generator.py, generate resources for 21w14a - 17w46a
This commit is contained in:
parent
eac5a2ca67
commit
4b36103db1
@ -57,7 +57,7 @@ public final class Minosoft {
|
|||||||
public static final HashSet<EventManager> EVENT_MANAGERS = new HashSet<>();
|
public static final HashSet<EventManager> EVENT_MANAGERS = new HashSet<>();
|
||||||
public static final HashBiMap<Integer, PlayConnection> CONNECTIONS = HashBiMap.create();
|
public static final HashBiMap<Integer, PlayConnection> CONNECTIONS = HashBiMap.create();
|
||||||
private static final CountUpAndDownLatch START_STATUS_LATCH = new CountUpAndDownLatch(1);
|
private static final CountUpAndDownLatch START_STATUS_LATCH = new CountUpAndDownLatch(1);
|
||||||
private static Configuration config;
|
public static Configuration config;
|
||||||
private static boolean isExiting;
|
private static boolean isExiting;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -71,10 +71,12 @@ class MinecraftAssetsManager(
|
|||||||
fun generateJarAssets(): String {
|
fun generateJarAssets(): String {
|
||||||
val startTime = System.currentTimeMillis()
|
val startTime = System.currentTimeMillis()
|
||||||
Log.verbose("Generating client.jar assets for %s...", this.assetVersion.version)
|
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
|
// ToDo: Verify all jar assets
|
||||||
Log.verbose("client.jar assets probably already generated for %s, skipping", this.assetVersion.version)
|
Log.verbose("client.jar assets probably already generated for %s, skipping", this.assetVersion.version)
|
||||||
return this.assetVersion.jarAssetsHash
|
return this.assetVersion.jarAssetsHash
|
||||||
|
|
||||||
}
|
}
|
||||||
// download jar
|
// download jar
|
||||||
downloadAsset(String.format(ProtocolDefinition.MOJANG_LAUNCHER_URL_PACKAGES, this.assetVersion.clientJarHash, "client.jar"), this.assetVersion.clientJarHash!!, true)
|
downloadAsset(String.format(ProtocolDefinition.MOJANG_LAUNCHER_URL_PACKAGES, this.assetVersion.clientJarHash, "client.jar"), this.assetVersion.clientJarHash!!, true)
|
||||||
|
@ -16,6 +16,8 @@ package de.bixilon.minosoft.generator;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
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.MinecraftAssetsManager;
|
||||||
import de.bixilon.minosoft.data.assets.Resources;
|
import de.bixilon.minosoft.data.assets.Resources;
|
||||||
import de.bixilon.minosoft.data.mappings.versions.Version;
|
import de.bixilon.minosoft.data.mappings.versions.Version;
|
||||||
@ -24,6 +26,7 @@ import java.io.*;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
public class JarHashGenerator {
|
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 {
|
public static void main(String[] args) throws IOException {
|
||||||
if (args.length != 1) {
|
if (args.length != 1) {
|
||||||
@ -31,9 +34,12 @@ public class JarHashGenerator {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
Minosoft.config = new Configuration();
|
||||||
|
|
||||||
|
|
||||||
Version version = new Version(args[0], -1, -1, Collections.emptyMap(), Collections.emptyMap());
|
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");
|
JsonObject versions = json.getAsJsonObject("versions");
|
||||||
@ -42,7 +48,8 @@ public class JarHashGenerator {
|
|||||||
|
|
||||||
Resources.loadVersion(version, versionJson);
|
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();
|
String jarAssetsHash = assetsManager.generateJarAssets();
|
||||||
|
|
||||||
versionJson.addProperty("jar_assets_hash", jarAssetsHash);
|
versionJson.addProperty("jar_assets_hash", jarAssetsHash);
|
||||||
@ -50,18 +57,17 @@ public class JarHashGenerator {
|
|||||||
|
|
||||||
// reload json, because the generator is async
|
// 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);
|
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());
|
FileWriter writer = new FileWriter(file.getAbsoluteFile());
|
||||||
writer.write(new Gson().toJson(json));
|
writer.write(new Gson().toJson(json));
|
||||||
writer.close();
|
writer.close();
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
throw new RuntimeException(e);
|
||||||
System.exit(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -9,7 +9,6 @@
|
|||||||
#
|
#
|
||||||
# This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
# This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
|
||||||
import os
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
|
||||||
@ -17,49 +16,38 @@ import ujson
|
|||||||
|
|
||||||
print("Minecraft mappings downloader (and generator)")
|
print("Minecraft mappings downloader (and generator)")
|
||||||
|
|
||||||
DOWNLOAD_UNTIL_VERSION = "18w01a"
|
DOWNLOAD_UNTIL_VERSION = "17w45b"
|
||||||
SKIP_VERSIONS = ["1.13-pre6", "1.13-pre5"]
|
SKIP_VERSIONS = []
|
||||||
DATA_FOLDER = "../data/resources/"
|
RESOURCE_MAPPINGS_INDEX_PATH = "../src/main/resources/assets/minosoft/mapping/resources.json"
|
||||||
TEMP_FOLDER = DATA_FOLDER + "tmp/"
|
RESOURCE_MAPPINGS_INDEX = ujson.load(open(RESOURCE_MAPPINGS_INDEX_PATH))
|
||||||
DOWNLOAD_BASE_URL = "https://apimon.de/mcdata/"
|
|
||||||
RESOURCE_MAPPINGS_INDEX = ujson.load(open("../src/main/resources/assets/mapping/resources.json"))
|
|
||||||
VERSION_MANIFEST = ujson.loads(urllib.request.urlopen('https://launchermeta.mojang.com/mc/game/version_manifest.json').read().decode("utf-8"))
|
VERSION_MANIFEST = ujson.loads(urllib.request.urlopen('https://launchermeta.mojang.com/mc/game/version_manifest.json').read().decode("utf-8"))
|
||||||
VERBOSE_LOG = False
|
VERBOSE_LOG = False
|
||||||
|
SKIP_COMPILE = False
|
||||||
failedVersionIds = []
|
failedVersionIds = []
|
||||||
partlyFailedVersionIds = []
|
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):
|
def generateJarAssets(versionId):
|
||||||
print("Generating jar asset hash: %s" % versionId)
|
print("Generating jar asset hash: %s" % versionId)
|
||||||
generateProcess = ""
|
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)
|
||||||
try:
|
exitCode = process.wait()
|
||||||
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
|
||||||
global RESOURCE_MAPPINGS_INDEX
|
RESOURCE_MAPPINGS_INDEX = ujson.load(open(RESOURCE_MAPPINGS_INDEX_PATH))
|
||||||
RESOURCE_MAPPINGS_INDEX = ujson.load(open("../src/main/resources/assets/mapping/resources.json"))
|
|
||||||
except Exception:
|
if exitCode != 0:
|
||||||
print(generateProcess.stdout)
|
print(process.stdout.read().decode('utf-8'))
|
||||||
print(generateProcess.stderr)
|
print(process.stderr.read().decode('utf-8'))
|
||||||
|
|
||||||
|
|
||||||
print("Compiling minosoft...")
|
if not SKIP_COMPILE:
|
||||||
compileProcess = ""
|
print("Compiling minosoft...")
|
||||||
try:
|
compileProcess = subprocess.Popen(r'mvn compile', shell=True, cwd='../', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
compileProcess = subprocess.run(r'mvn compile', shell=True, check=True, cwd='../', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
compileExitCode = compileProcess.wait()
|
||||||
except Exception:
|
if compileExitCode != 0:
|
||||||
print(compileProcess.stdout)
|
print(compileProcess.stdout.read().decode('utf-8'))
|
||||||
print(compileProcess.stderr)
|
print(compileProcess.stderr.read().decode('utf-8'))
|
||||||
exit(1)
|
print("Minosoft compiled!")
|
||||||
print("Minosoft compiled!")
|
|
||||||
|
|
||||||
|
|
||||||
def downloadVersion(version):
|
def downloadVersion(version):
|
||||||
@ -68,8 +56,9 @@ def downloadVersion(version):
|
|||||||
print("Force skipping %s" % version["id"])
|
print("Force skipping %s" % version["id"])
|
||||||
return
|
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"])
|
print("Skipping %s" % version["id"])
|
||||||
|
return
|
||||||
print()
|
print()
|
||||||
|
|
||||||
print("DEBUG: Downloading versions json for %s" % version["id"])
|
print("DEBUG: Downloading versions json for %s" % version["id"])
|
||||||
@ -81,20 +70,16 @@ def downloadVersion(version):
|
|||||||
resourcesVersion["client_jar_hash"] = versionJson["downloads"]["client"]["sha1"]
|
resourcesVersion["client_jar_hash"] = versionJson["downloads"]["client"]["sha1"]
|
||||||
RESOURCE_MAPPINGS_INDEX["versions"][version["id"]] = resourcesVersion
|
RESOURCE_MAPPINGS_INDEX["versions"][version["id"]] = resourcesVersion
|
||||||
# dump resources index
|
# 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)
|
ujson.dump(RESOURCE_MAPPINGS_INDEX, file)
|
||||||
# start jar hash generator
|
# start jar hash generator
|
||||||
try:
|
try:
|
||||||
generateJarAssets(version["id"])
|
generateJarAssets(version["id"])
|
||||||
except Exception:
|
except Exception:
|
||||||
failedVersionIds.append(version["id"])
|
failedVersionIds.append(version["id"])
|
||||||
|
print("%s failed!" % version["id"])
|
||||||
return
|
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"]:
|
for version in VERSION_MANIFEST["versions"]:
|
||||||
if version["id"] == DOWNLOAD_UNTIL_VERSION:
|
if version["id"] == DOWNLOAD_UNTIL_VERSION:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user