From e990741b18d9f5dcdf7069c71c400927c5fec0cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 16 Oct 2020 18:38:29 +0200 Subject: [PATCH] Support initial XBox compliance level --- generateMojang.py | 2 +- metautil.py | 23 +++++++++++++++++++++++ update.sh | 2 +- updateMojang.py | 6 +++--- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/generateMojang.py b/generateMojang.py index 353271d..4883698 100755 --- a/generateMojang.py +++ b/generateMojang.py @@ -313,7 +313,7 @@ def processSingleVariant(lwjglVariant): lwjglSharedData.recommended = ['3.1.2'] lwjglSharedData.write() -with open("upstream/mojang/version_manifest.json", 'r', encoding='utf-8') as localIndexFile: +with open("upstream/mojang/version_manifest_v2.json", 'r', encoding='utf-8') as localIndexFile: localVersionlist = MojangIndexWrap(json.load(localIndexFile)) mcSharedData = MultiMCSharedPackageData(uid = 'net.minecraft', name = 'Minecraft') diff --git a/metautil.py b/metautil.py index e228b11..26744d6 100644 --- a/metautil.py +++ b/metautil.py @@ -118,6 +118,8 @@ class MojangIndexEntry(JsonObject): time = ISOTimestampProperty() type = StringProperty() url = StringProperty() + sha1 = StringProperty(exclude_if_none=True, default=None) + complianceLevel = IntegerProperty(exclude_if_none=True, default=None) class MojangIndex(JsonObject): latest = DictProperty(StringProperty) @@ -223,6 +225,7 @@ class MojangVersionFile (JsonObject): type = StringProperty(exclude_if_none=True, default=None) inheritsFrom = StringProperty(exclude_if_none=True, default=None) logging = DictProperty(MojangLogging, exclude_if_none=True, default=None) + complianceLevel = IntegerProperty(exclude_if_none=True, default=None) CurrentMultiMCFormatVersion = 1 @@ -263,6 +266,16 @@ class MultiMCVersionFile (VersionedJsonObject): addTweakers = ListProperty(StringProperty, name="+tweakers", exclude_if_none=True, default=None) order = IntegerProperty(exclude_if_none=True, default=None) +class UnknownComplianceLevelException(Exception): + """Exception raised for unknown Mojang compliance level + + Attributes: + message -- explanation of the error + """ + def __init__(self, message): + self.message = message + + # Convert Mojang version file object to a MultiMC version file object def MojangToMultiMC (file, name, uid, version): mmcFile = MultiMCVersionFile( @@ -294,6 +307,16 @@ def MojangToMultiMC (file, name, uid, version): mmcFile.releaseTime = file.releaseTime # time should not be set. mmcFile.type = file.type + maxSupportedLevel = 1 + if file.complianceLevel: + if file.complianceLevel == 0: + pass + elif file.complianceLevel == 1: + if not mmcFile.addTraits: + mmcFile.addTraits = [] + mmcFile.addTraits.append("XR:Initial") + else: + raise UnknownComplianceLevelException("Unsupported Mojang compliance level: %d. Max supported is: %d" % (file.complianceLevel, maxSupportedLevel)) return mmcFile class MultiMCSharedPackageData(VersionedJsonObject): diff --git a/update.sh b/update.sh index cae1776..05543d3 100755 --- a/update.sh +++ b/update.sh @@ -45,7 +45,7 @@ cd "${BASEDIR}" if [ "${DEPLOY_TO_GIT}" = true ] ; then cd "${BASEDIR}/${UPSTREAM_DIR}" - git add mojang/version_manifest.json mojang/versions/* mojang/assets/* || fail_in + git add mojang/version_manifest_v2.json mojang/versions/* mojang/assets/* || fail_in git add forge/*.json forge/version_manifests/*.json forge/installer_manifests/*.json forge/files_manifests/*.json forge/installer_info/*.json || fail_in git add fabric/loader-installer-json/*.json fabric/meta-v2/*.json fabric/jars/*.json || fail_in git add liteloader/*.json || fail_in diff --git a/updateMojang.py b/updateMojang.py index 8c4637e..c8ad455 100755 --- a/updateMojang.py +++ b/updateMojang.py @@ -29,14 +29,14 @@ def get_file(path, url): # get the local version list localVersionlist = None try: - with open("upstream/mojang/version_manifest.json", 'r', encoding='utf-8') as localIndexFile: + with open("upstream/mojang/version_manifest_v2.json", 'r', encoding='utf-8') as localIndexFile: localVersionlist = MojangIndexWrap(json.load(localIndexFile)) except: localVersionlist = MojangIndexWrap({}) localIDs = set(localVersionlist.versions.keys()) # get the remote version list -r = sess.get('https://launchermeta.mojang.com/mc/game/version_manifest.json') +r = sess.get('https://launchermeta.mojang.com/mc/game/version_manifest_v2.json') r.raise_for_status() main_json = r.json() remoteVersionlist = MojangIndexWrap(main_json) @@ -68,5 +68,5 @@ def get_file(path, url): print("assets", assetId, assetUrl) get_file( "upstream/mojang/assets/" + assetId + '.json', assetUrl) -with open("upstream/mojang/version_manifest.json", 'w', encoding='utf-8') as f: +with open("upstream/mojang/version_manifest_v2.json", 'w', encoding='utf-8') as f: json.dump(main_json, f, sort_keys=True, indent=4)