improve assets properties generation code

This commit is contained in:
Moritz Zwerger 2023-11-05 14:35:59 +01:00
parent 43eb1ff4d1
commit b4ed972efd
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
4 changed files with 32 additions and 17 deletions

View File

@ -11,8 +11,7 @@
"type": "object", "type": "object",
"properties": { "properties": {
"index_version": { "index_version": {
"type": "string", "type": "string"
"pattern": "\\d+\\.\\d{1,2}"
}, },
"index_hash": { "index_hash": {
"$ref": "#/definitions/hash" "$ref": "#/definitions/hash"

View File

@ -17,11 +17,9 @@ import de.bixilon.kutil.reflection.ReflectionUtil.forceInit
import de.bixilon.minosoft.assets.InvalidAssetException import de.bixilon.minosoft.assets.InvalidAssetException
import de.bixilon.minosoft.assets.minecraft.JarAssetsManager import de.bixilon.minosoft.assets.minecraft.JarAssetsManager
import de.bixilon.minosoft.config.profile.profiles.resources.ResourcesProfileManager import de.bixilon.minosoft.config.profile.profiles.resources.ResourcesProfileManager
import de.bixilon.minosoft.protocol.packets.registry.PacketMapping
import de.bixilon.minosoft.protocol.protocol.PacketDirections
import de.bixilon.minosoft.protocol.versions.Version import de.bixilon.minosoft.protocol.versions.Version
import de.bixilon.minosoft.protocol.versions.VersionTypes
import de.bixilon.minosoft.util.logging.Log import de.bixilon.minosoft.util.logging.Log
import org.objenesis.ObjenesisStd
import kotlin.system.exitProcess import kotlin.system.exitProcess
object AssetsPropertiesGenerator { object AssetsPropertiesGenerator {
@ -29,17 +27,19 @@ object AssetsPropertiesGenerator {
@JvmStatic @JvmStatic
fun main(args: Array<String>) { fun main(args: Array<String>) {
val stream = System.out val stream = System.out
System.setOut(System.err)
Log::class.java.forceInit() Log::class.java.forceInit()
if (args.size != 2) { Log.ASYNC_LOGGING = false
throw IllegalArgumentException("Usage: application <version id> <client jar hash>") if (args.size != 1) {
throw IllegalArgumentException("Usage: application <client jar hash>")
} }
// create profile to not make crashes (or load an actual profile) // create profile to not make crashes (or load an actual profile)
val profile = ResourcesProfileManager.createProfile() val profile = ResourcesProfileManager.createProfile()
profile.verify = false profile.verify = false
val (versionId, clientJarHash) = args val (clientJarHash) = args
val version = Version(versionId, -1, -1, VersionTypes.APRIL_FOOL, PacketMapping(PacketDirections.SERVER_TO_CLIENT), PacketMapping(PacketDirections.CLIENT_TO_SERVER)) val version = ObjenesisStd().newInstance(Version::class.java)
val assetsManager = JarAssetsManager("829c3804401b0727f70f73d4415e162400cbe57b", clientJarHash, profile, version) val assetsManager = JarAssetsManager("0000000000000000000000000000000000000000", clientJarHash, profile, version)
try { try {
assetsManager.load() assetsManager.load()
} catch (exception: InvalidAssetException) { } catch (exception: InvalidAssetException) {

File diff suppressed because one or more lines are too long

View File

@ -8,6 +8,22 @@
# You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. # You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
# #
# 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.
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# This software is not affiliated with Mojang AB, the original developer of Minecraft.
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# This software is not affiliated with Mojang AB, the original developer of Minecraft.
import subprocess import subprocess
import ujson import ujson
@ -24,8 +40,8 @@ VERSION_MANIFEST = ujson.loads(urllib.request.urlopen('https://launchermeta.moja
PIXLYZER_INDEX = ujson.loads(urllib.request.urlopen('https://gitlab.bixilon.de/bixilon/pixlyzer-data/-/raw/master/mbf_index.min.json?inline=false').read().decode("utf-8")) PIXLYZER_INDEX = ujson.loads(urllib.request.urlopen('https://gitlab.bixilon.de/bixilon/pixlyzer-data/-/raw/master/mbf_index.min.json?inline=false').read().decode("utf-8"))
def generate_jar_assets(version_id, assets_properties): def generate_jar_assets(assets_properties):
process = subprocess.Popen(r'./gradlew -q assetsProperties --args="\"%s\" \"%s\""' % (version_id, assets_properties["client_jar_hash"]), shell=True, cwd='../', stdout=subprocess.PIPE, stderr=subprocess.PIPE) process = subprocess.Popen(r'./gradlew -q assetsProperties --args="\"%s\""' % (assets_properties["client_jar_hash"]), shell=True, cwd='../', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
exit_code = process.wait() exit_code = process.wait()
if exit_code != 0: if exit_code != 0:
print(process.stdout.read().decode('utf-8')) print(process.stdout.read().decode('utf-8'))
@ -35,7 +51,7 @@ def generate_jar_assets(version_id, assets_properties):
(hash, tar_bytes) = process.stdout.read().decode('utf-8').split(":") (hash, tar_bytes) = process.stdout.read().decode('utf-8').split(":")
assets_properties["jar_assets_hash"] = hash assets_properties["jar_assets_hash"] = hash
assets_properties["jar_assets_tar_bytes"] = tar_bytes assets_properties["jar_assets_tar_bytes"] = int(tar_bytes)
def generate_version(version): def generate_version(version):
@ -67,10 +83,10 @@ def generate_version(version):
if "jar_assets_hash" not in assets_properties: if "jar_assets_hash" not in assets_properties:
try: try:
generate_jar_assets(version["id"], assets_properties) generate_jar_assets(assets_properties)
changed = True changed = True
except Exception: except Exception as e:
print("%s failed!" % version["id"]) print("%s failed: %s" % (version["id"], str(e)))
return return
return changed return changed