Skip to content

Commit

Permalink
Support initial XBox compliance level
Browse files Browse the repository at this point in the history
  • Loading branch information
peterix committed Oct 16, 2020
1 parent bac4de1 commit e990741
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion generateMojang.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
23 changes: 23 additions & 0 deletions metautil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions updateMojang.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

0 comments on commit e990741

Please sign in to comment.