From 3de5255f43bf18a8f5934c9687a6343b6ec55aac Mon Sep 17 00:00:00 2001 From: nea Date: Fri, 10 Mar 2023 22:04:34 +0100 Subject: Manual merge --- build.gradle.kts | 1 + src/main/kotlin/mcprepack/App.kt | 31 +++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 1fa7c68..0750742 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -28,6 +28,7 @@ dependencies { implementation("com.github.jponge:lzma-java:1.3") implementation("com.nothome:javaxdelta:2.0.1") // TODO maybe remove? implementation("com.google.code.gson:gson:2.10.1") + implementation("net.minecraftforge:mergetool:1.1.5") } application { diff --git a/src/main/kotlin/mcprepack/App.kt b/src/main/kotlin/mcprepack/App.kt index 52d2680..cbd8288 100644 --- a/src/main/kotlin/mcprepack/App.kt +++ b/src/main/kotlin/mcprepack/App.kt @@ -9,6 +9,7 @@ import lzma.sdk.lzma.Encoder import lzma.streams.LzmaInputStream import lzma.streams.LzmaOutputStream import net.fabricmc.stitch.commands.tinyv2.* +import net.minecraftforge.mergetool.Merger import net.minecraftforge.srgutils.IMappingFile import net.minecraftforge.srgutils.INamedMappingFile import org.objectweb.asm.ClassReader @@ -29,7 +30,7 @@ val gson = GsonBuilder() fun main(): Unit = lifecycle("Repacking") { val mavenModulePub = "test" val pubVersion = "1.8.9" - + val accessVersion = "1.8.9" WorkContext.setupWorkSpace() val downloadDebugFiles = true @@ -67,6 +68,7 @@ fun main(): Unit = lifecycle("Repacking") { ?.let(FileSystems::newFileSystem) } + val variousTinies by lifecycle("Generate Tiny classes") { val classes = INamedMappingFile.load(Files.newInputStream(mcpSrgFs.getPath("joined.srg"))) val tinyTemp = WorkContext.file("tiny-joined", "tiny") @@ -78,7 +80,32 @@ fun main(): Unit = lifecycle("Repacking") { val classesTiny by lazy { variousTinies.first } val classesTsrg by lazy { variousTinies.second } - val minecraftjar by lifecycle("Load Minecraft Jar") { + val minecraftManifest by lifecycle("Resolve minecraft manifest") { + val f = WorkContext.file("version-manifest", "json") + require(WorkContext.httpGet("https://piston-meta.mojang.com/mc/game/version_manifest_v2.json", f)) + val vm = gson.fromJson(f.readText(), JsonObject::class.java) + val version = vm["versions"].asJsonArray.map { it.asJsonObject } + .find { it["id"].asString == accessVersion } ?: error("Could not find minecraft version $accessVersion") + val cf = WorkContext.file("version", "json") + require(WorkContext.httpGet(version["url"].asString, cf)) + gson.fromJson(cf.readText(), JsonObject::class.java) + } + + val clientJar by lifecycle("Download client jar") { + val f = WorkContext.file("minecraft-client", "jar") + WorkContext.httpGet(minecraftManifest["downloads"].asJsonObject["client"].asJsonObject["url"].asString, f) + f + } + + val serverJar by lifecycle("Download server jar") { + val f = WorkContext.file("minecraft-server", "jar") + WorkContext.httpGet(minecraftManifest["downloads"].asJsonObject["server"].asJsonObject["url"].asString, f) + f + } + + val minecraftjar by lifecycle("Merge Minecraft Jar") { + val f = WorkContext.file("minecraft-merged", "jar") + Merger(clientJar.toFile(), serverJar.toFile(), f.toFile()).process() FileSystems.newFileSystem(Path.of("minecraft-merged.jar")) } -- cgit