add client/server jar merging
All checks were successful
Publish to snapshot maven / build (push) Successful in 55s
All checks were successful
Publish to snapshot maven / build (push) Successful in 55s
This commit is contained in:
parent
64adbe82a5
commit
15987c805b
|
@ -7,7 +7,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = "dev.frogmc"
|
||||
version = "0.0.1-alpha.25" + ("+local".takeUnless { project.hasProperty("FrogMCSnapshotsMavenPassword") } ?: "")
|
||||
version = "0.0.1-alpha.26" + ("+local".takeUnless { project.hasProperty("FrogMCSnapshotsMavenPassword") } ?: "")
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
|
@ -24,7 +24,7 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation("dev.frogmc:thyroxine:0.0.1-alpha.16")
|
||||
implementation("dev.frogmc:thyroxine:0.0.1-alpha.17")
|
||||
implementation("org.ow2.asm:asm:9.7")
|
||||
implementation("org.ow2.asm:asm-commons:9.7")
|
||||
implementation("org.ow2.asm:asm-tree:9.7")
|
||||
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
|||
#Sun May 12 17:35:40 BST 2024
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package dev.frogmc.phytotelma
|
||||
|
||||
import com.electronwill.nightconfig.core.CommentedConfig
|
||||
import com.electronwill.nightconfig.core.file.FileNotFoundAction
|
||||
import com.electronwill.nightconfig.core.io.WritingMode
|
||||
import com.electronwill.nightconfig.toml.TomlParser
|
||||
import com.electronwill.nightconfig.toml.TomlWriter
|
||||
import dev.frogmc.phytotelma.accesswidener.AccessWidener
|
||||
|
@ -13,7 +11,6 @@ import dev.frogmc.phytotelma.ext.PhytotelmaGradleExtensionImpl
|
|||
import dev.frogmc.phytotelma.mappings.renameDstNamespace
|
||||
import dev.frogmc.phytotelma.mixin.remapper.MixinAnnotationRemapper
|
||||
import dev.frogmc.phytotelma.nest.NestStripper
|
||||
import dev.frogmc.phytotelma.nest.Nester
|
||||
import dev.frogmc.phytotelma.run.AssetDownloader
|
||||
import dev.frogmc.phytotelma.run.RunConfigGenerator
|
||||
import dev.frogmc.phytotelma.run.task.RunGameTask
|
||||
|
@ -31,6 +28,7 @@ import org.gradle.api.Project
|
|||
import org.gradle.api.plugins.JavaBasePlugin
|
||||
import org.gradle.api.plugins.JavaPlugin
|
||||
import org.gradle.api.tasks.Delete
|
||||
import org.gradle.internal.impldep.org.jsoup.helper.Consumer
|
||||
import org.jetbrains.java.decompiler.main.Fernflower
|
||||
import org.jetbrains.java.decompiler.main.decompiler.PrintStreamLogger
|
||||
import org.jetbrains.java.decompiler.main.decompiler.SingleFileSaver
|
||||
|
@ -40,10 +38,8 @@ import java.io.OutputStream
|
|||
import java.io.PrintStream
|
||||
import java.net.URI
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.nio.file.FileSystems
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.StandardCopyOption
|
||||
import java.nio.file.*
|
||||
import java.nio.file.attribute.BasicFileAttributes
|
||||
import java.time.LocalDateTime
|
||||
import java.util.*
|
||||
import kotlin.io.path.*
|
||||
|
@ -209,7 +205,8 @@ class PhytotelmaPlugin : Plugin<Project> {
|
|||
val moj = if (storage.intermediaryNs == Constants.MOJMAP_NAMESPACE) {
|
||||
MojmapProvider.get(
|
||||
storage.minecraftVersion!!,
|
||||
globalCacheDir.resolve("net/minecraft/client/${storage.minecraftVersion}/client-${storage.minecraftVersion}.txt")
|
||||
globalCacheDir.resolve("net/minecraft/client/${storage.minecraftVersion}/client-${storage.minecraftVersion}.txt"),
|
||||
globalCacheDir.resolve("net/minecraft/server/${storage.minecraftVersion}/server-${storage.minecraftVersion}.txt")
|
||||
).reverse().renameDstNamespace(Constants.MOJMAP_NAMESPACE)
|
||||
} else null
|
||||
val mappings = (moj?.let {
|
||||
|
@ -276,10 +273,10 @@ class PhytotelmaPlugin : Plugin<Project> {
|
|||
}
|
||||
}
|
||||
|
||||
private fun defaultRemappingSteps(sourceNsJar: Path): MutableList<RemappingStep> {
|
||||
private fun defaultRemappingSteps(vararg sourceNSJars: Path): MutableList<RemappingStep> {
|
||||
return mutableListOf(
|
||||
RemappingStep(::ClassRemapper),
|
||||
RemappingStep { cv, mapper -> MixinAnnotationRemapper(cv, mapper, sourceNsJar) },
|
||||
RemappingStep { cv, mapper -> MixinAnnotationRemapper(cv, mapper, *sourceNSJars) },
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -289,7 +286,8 @@ class PhytotelmaPlugin : Plugin<Project> {
|
|||
System.setOut(PrintStream(OutputStream.nullOutputStream()))
|
||||
val mojmapGameJar = ProjectStorage.get(project).remappedGameJarPath!!.resolveSibling("mojmap.jar")
|
||||
val version = ProjectStorage.get(project).minecraftVersion!!
|
||||
val officialJar = VersionChecker.downloadClient(project, version)
|
||||
val officialClientJar = VersionChecker.downloadClient(project, version)
|
||||
val officialServerJar = VersionChecker.downloadServer(project, version)
|
||||
ModConfigurations.configurations.forEach { conf ->
|
||||
val artifacts = project.configurations.getByName("mod" + conf.name.replaceFirstChar {
|
||||
if (it.isLowerCase()) it.titlecase(
|
||||
|
@ -300,8 +298,32 @@ class PhytotelmaPlugin : Plugin<Project> {
|
|||
if (artifacts.isEmpty()) {
|
||||
return
|
||||
}
|
||||
val mojmap = MojmapProvider.get(version,
|
||||
globalCacheDir.resolve("net/minecraft/client/${version}/client-${version}.txt"),
|
||||
globalCacheDir.resolve("net/minecraft/server/${version}/server-${version}.txt"))
|
||||
if (mojmapGameJar.notExists()) {
|
||||
Thyroxine.run(version, officialJar, mojmapGameJar, true, false)
|
||||
val remappedClient = officialClientJar.resolveSibling("client-$version-mojmap.jar")
|
||||
val remappedServer = officialServerJar.resolveSibling("server-$version-mojmap.jar")
|
||||
Thyroxine.remap(mojmap.data.first(), officialClientJar, remappedClient, true, false)
|
||||
Thyroxine.remap(mojmap.data.first(), officialServerJar, remappedServer, true, false)
|
||||
FileSystems.newFileSystem(mojmapGameJar, mutableMapOf<String, String>("create" to "true")).use { mergedFs ->
|
||||
val consumer = object : Consumer<FileSystem> {
|
||||
override fun accept(fs: FileSystem) {
|
||||
Files.walkFileTree(fs.getPath("/"), object : SimpleFileVisitor<Path>() {
|
||||
override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult {
|
||||
val target = mergedFs.getPath(file.toString())
|
||||
target.createParentDirectories()
|
||||
if (target.notExists()) {
|
||||
file.copyTo(target)
|
||||
}
|
||||
return super.visitFile(file, attrs)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
FileSystems.newFileSystem(remappedClient).use { consumer.accept(it) }
|
||||
FileSystems.newFileSystem(remappedServer).use { consumer.accept(it) }
|
||||
}
|
||||
}
|
||||
val target = project.configurations.create("mod" + conf.name.replaceFirstChar {
|
||||
if (it.isLowerCase()) it.titlecase(
|
||||
|
@ -323,10 +345,7 @@ class PhytotelmaPlugin : Plugin<Project> {
|
|||
MappingBundle(officialStore),
|
||||
project.projectDir.resolve("officialStore.tiny").toPath().writer()
|
||||
)
|
||||
val mojOfficial = MojmapProvider.get(
|
||||
storage.minecraftVersion!!,
|
||||
globalCacheDir.resolve("net/minecraft/client/${storage.minecraftVersion}/client-${storage.minecraftVersion}.txt")
|
||||
).reverse().renameDstNamespace(Constants.MOJMAP_NAMESPACE).data[0].reverse()
|
||||
val mojOfficial = mojmap.reverse().renameDstNamespace(Constants.MOJMAP_NAMESPACE).data[0].reverse()
|
||||
val targetPath = project.layout.buildDirectory.asFile.get().toPath().resolve("remappedMods")
|
||||
.resolve("dev/frogmc/phytotelma/remapped_mods")
|
||||
val remappedPaths = mutableListOf<Path>()
|
||||
|
@ -362,8 +381,8 @@ class PhytotelmaPlugin : Plugin<Project> {
|
|||
)
|
||||
Thyroxine.remap(
|
||||
officialStore, temp, remappedPath, false, defaultRemappingSteps(
|
||||
officialJar
|
||||
), officialJar
|
||||
officialClientJar, officialServerJar
|
||||
), officialClientJar, officialServerJar
|
||||
)
|
||||
Files.deleteIfExists(temp)
|
||||
NestStripper.stripJij(remappedPath)
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.google.gson.GsonBuilder
|
|||
import dev.frogmc.phytotelma.common.CachingHttpClient
|
||||
import org.gradle.api.Project
|
||||
import java.net.URI
|
||||
import java.nio.file.FileSystems
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.*
|
||||
|
||||
|
@ -15,38 +16,85 @@ object VersionChecker {
|
|||
private var validVersions = mutableListOf<VersionUrl>()
|
||||
private var versionData: VersionData? = null
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
fun downloadServer(project: Project, version: String): Path {
|
||||
|
||||
fetchVersionData(project, version)
|
||||
val versionData = fetchServerDownload(project, version)
|
||||
val downloadDirectory = PhytotelmaPlugin.globalCacheDir.resolve("net/minecraft/server/$version/")
|
||||
val bundleFile = downloadDirectory.resolve("server-$version-bundle.jar")
|
||||
val downloadFile = downloadDirectory.resolve("server-$version.jar")
|
||||
if (!project.gradle.startParameter.isRefreshDependencies && bundleFile.exists()) {
|
||||
if (versionData.sha1 == Hashing.sha1().hashBytes(bundleFile.readBytes()).toString()) {
|
||||
if (downloadFile.exists()) {
|
||||
FileSystems.newFileSystem(bundleFile).use { fs ->
|
||||
val hash = fs.getPath("/META-INF/versions.list").readText().split("\t")[0]
|
||||
if (hash == Hashing.sha256().hashBytes(downloadFile.readBytes()).toString()) {
|
||||
return downloadFile
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
println("Downloading server...")
|
||||
downloadDirectory.createDirectories()
|
||||
val raw = rawDownload(versionData.url)
|
||||
bundleFile.writeBytes(raw)
|
||||
FileSystems.newFileSystem(bundleFile).use { fs ->
|
||||
val metaInf = fs.getPath("/META-INF")
|
||||
val versionsList = metaInf.resolve("versions.list").readText()
|
||||
val jar = metaInf.resolve("versions").resolve(versionsList.split("\t")[2])
|
||||
jar.copyTo(downloadFile)
|
||||
}
|
||||
|
||||
return downloadFile
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
fun downloadClient(project: Project, version: String): Path {
|
||||
|
||||
fetchVersionData(project, version)
|
||||
val clientData = fetchClientDownload(project, version)
|
||||
val versionData = fetchClientDownload(project, version)
|
||||
// download client data
|
||||
val downloadDirectory = PhytotelmaPlugin.globalCacheDir.resolve("net/minecraft/client/$version/")
|
||||
val downloadFile = downloadDirectory.resolve("client-$version.jar")
|
||||
if (!project.gradle.startParameter.isRefreshDependencies && downloadFile.exists()) {
|
||||
if (clientData.sha1 == Hashing.sha1().hashBytes(downloadFile.readBytes()).toString()) {
|
||||
if (versionData.sha1 == Hashing.sha1().hashBytes(downloadFile.readBytes()).toString()) {
|
||||
return downloadFile
|
||||
}
|
||||
}
|
||||
println("Downloading client...")
|
||||
downloadDirectory.createDirectories()
|
||||
val raw = rawDownload(clientData.url)
|
||||
val raw = rawDownload(versionData.url)
|
||||
downloadFile.writeBytes(raw)
|
||||
return downloadFile
|
||||
}
|
||||
|
||||
fun savePomFile(version: String, dir: Path) {
|
||||
fun saveClientPomFile(version: String, dir: Path) {
|
||||
savePomFile(version, dir, "client")
|
||||
}
|
||||
|
||||
fun saveServerPomFile(version: String, dir: Path) {
|
||||
savePomFile(version, dir, "server")
|
||||
}
|
||||
|
||||
fun saveMergedPomFile(version: String, dir: Path) {
|
||||
savePomFile(version, dir, "minecraft-merged")
|
||||
}
|
||||
|
||||
private fun savePomFile(version: String, dir: Path, name: String) {
|
||||
val content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
||||
"<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\" xmlns=\"http://maven.apache.org/POM/4.0.0\"\n" +
|
||||
"\t\t xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
|
||||
"\t<modelVersion>4.0.0</modelVersion>\n" +
|
||||
"\t<groupId>net.minecraft</groupId>\n" +
|
||||
"\t<artifactId>client</artifactId>\n" +
|
||||
"\t<artifactId>$name</artifactId>\n" +
|
||||
"\t<version>$version</version>\n" +
|
||||
"</project>"
|
||||
dir.resolve("client-$version.pom").writeText(content)
|
||||
dir.resolve("$name-$version.pom").writeText(content)
|
||||
}
|
||||
|
||||
|
||||
fun getDependencies(project: Project, version: String, action: (String) -> Unit) {
|
||||
fetchVersionData(project, version).libraries.map { it.name }.forEach {
|
||||
action.invoke(it)
|
||||
|
@ -78,10 +126,14 @@ object VersionChecker {
|
|||
return versionData!!
|
||||
}
|
||||
|
||||
fun fetchClientDownload(project: Project, version: String): VersionClientData {
|
||||
private fun fetchClientDownload(project: Project, version: String): VersionDownloadData {
|
||||
return fetchVersionData(project, version).downloads.client
|
||||
}
|
||||
|
||||
private fun fetchServerDownload(project: Project, version: String): VersionDownloadData {
|
||||
return fetchVersionData(project, version).downloads.server
|
||||
}
|
||||
|
||||
private fun rawDownload(url: String): ByteArray {
|
||||
return CachingHttpClient.getUncached(URI.create(url)).readAllBytes()
|
||||
}
|
||||
|
@ -133,6 +185,6 @@ class LibraryDownload(val artifact: LibraryArtifact, val name: String)
|
|||
class LibraryArtifact(val path: String, val sha1: String, val size: Int, val url: String)
|
||||
|
||||
class AssetIndex(val id: String, val sha1: String, val size: Int, val totalSize: Int, val url: String)
|
||||
class VersionDownloads(val client: VersionClientData)
|
||||
class VersionDownloads(val client: VersionDownloadData, val server: VersionDownloadData)
|
||||
|
||||
class VersionClientData(val sha1: String, val size: Int, val url: String)
|
||||
class VersionDownloadData(val sha1: String, val size: Int, val url: String)
|
||||
|
|
|
@ -52,7 +52,8 @@ abstract class MinecraftConfiguration @Inject constructor(
|
|||
return@provider MappingBundle.merge(
|
||||
MojmapProvider.get(
|
||||
version.get(),
|
||||
cacheDir.resolve("net/minecraft/client/${version.get()}/client-${version.get()}.txt")
|
||||
cacheDir.resolve("net/minecraft/client/${version.get()}/client-${version.get()}.txt"),
|
||||
cacheDir.resolve("net/minecraft/server/${version.get()}/server-${version.get()}.txt")
|
||||
).reverse(),
|
||||
ParchmentProvider.getParchment(
|
||||
conf.gameVersion.get(),
|
||||
|
@ -87,7 +88,8 @@ abstract class MinecraftConfiguration @Inject constructor(
|
|||
targetNamespace = Constants.MOJMAP_NAMESPACE
|
||||
return@provider MojmapProvider.get(
|
||||
version.get(),
|
||||
cacheDir.resolve("net/minecraft/client/${version.get()}/client-${version.get()}.txt")
|
||||
cacheDir.resolve("net/minecraft/client/${version.get()}/client-${version.get()}.txt"),
|
||||
cacheDir.resolve("net/minecraft/server/${version.get()}/server-${version.get()}.txt")
|
||||
).reverse().renameDstNamespace(targetNamespace)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,11 @@ import org.gradle.api.Action
|
|||
import org.gradle.api.Project
|
||||
import org.gradle.api.model.ObjectFactory
|
||||
import org.gradle.api.plugins.JavaPlugin
|
||||
import java.nio.file.Files
|
||||
import org.gradle.internal.impldep.org.jsoup.helper.Consumer
|
||||
import java.nio.file.*
|
||||
import java.nio.file.attribute.BasicFileAttributes
|
||||
import javax.inject.Inject
|
||||
import kotlin.io.path.copyTo
|
||||
import kotlin.io.path.createParentDirectories
|
||||
import kotlin.io.path.notExists
|
||||
|
||||
|
@ -46,21 +49,61 @@ abstract class PhytotelmaGradleExtensionImpl @Inject constructor(
|
|||
projectData.mappings = mappings
|
||||
|
||||
val clientJar = VersionChecker.downloadClient(project, version)
|
||||
val remappedJar =
|
||||
val serverJar = VersionChecker.downloadServer(project, version)
|
||||
val remappedClientJar =
|
||||
projectData.localCacheDir!!.resolve("net/minecraft/client/$version/client-$version-remapped.jar")
|
||||
remappedJar.createParentDirectories()
|
||||
projectData.remappedGameJarPath = remappedJar
|
||||
var applyAW = AccessWidener.needsUpdate(project)
|
||||
projectData.intermediaryNs = mcConf.intermediaryNamespace.get()
|
||||
if (remappedJar.notExists() || applyAW || mcConf.mappingsName != projectData.mappingsName) {
|
||||
projectData.mappingsName = mcConf.mappingsName
|
||||
println("Remapping the game...")
|
||||
projectData.targetNamespace = mcConf.targetNamespace
|
||||
val remappedServerJar =
|
||||
projectData.localCacheDir!!.resolve("net/minecraft/server/$version/server-$version-remapped.jar")
|
||||
remappedClientJar.createParentDirectories()
|
||||
remappedServerJar.createParentDirectories()
|
||||
if (remappedClientJar.notExists() || mcConf.mappingsName != projectData.mappingsName) {
|
||||
println("Remapping client...")
|
||||
Thyroxine.remap(
|
||||
mappings.forNamespaces("official", mcConf.targetNamespace),
|
||||
clientJar, remappedJar, true, true
|
||||
clientJar, remappedClientJar, true, true
|
||||
)
|
||||
VersionChecker.savePomFile(version, remappedJar.parent)
|
||||
VersionChecker.saveClientPomFile(version, remappedClientJar.parent)
|
||||
}
|
||||
if (remappedServerJar.notExists() || mcConf.mappingsName != projectData.mappingsName) {
|
||||
println("Remapping server...")
|
||||
Thyroxine.remap(
|
||||
mappings.forNamespaces("official", mcConf.targetNamespace),
|
||||
serverJar, remappedServerJar, true, true
|
||||
)
|
||||
VersionChecker.saveServerPomFile(version, remappedServerJar.parent)
|
||||
}
|
||||
val mergedJar =
|
||||
projectData.localCacheDir!!.resolve("net/minecraft/minecraft-merged/$version/minecraft-merged-$version.jar")
|
||||
projectData.remappedGameJarPath = mergedJar
|
||||
var applyAW = AccessWidener.needsUpdate(project)
|
||||
projectData.intermediaryNs = mcConf.intermediaryNamespace.get()
|
||||
if (mergedJar.notExists() || applyAW || mcConf.mappingsName != projectData.mappingsName) {
|
||||
projectData.mappingsName = mcConf.mappingsName
|
||||
println("Merging game...")
|
||||
|
||||
FileSystems.newFileSystem(mergedJar, mutableMapOf<String, String>("create" to "true")).use { mergedFs ->
|
||||
val consumer = object : Consumer<FileSystem> {
|
||||
override fun accept(fs: FileSystem) {
|
||||
Files.walkFileTree(fs.getPath("/"), object : SimpleFileVisitor<Path>() {
|
||||
override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult {
|
||||
val target = mergedFs.getPath(file.toString())
|
||||
target.createParentDirectories()
|
||||
if (target.notExists()) {
|
||||
file.copyTo(target)
|
||||
}
|
||||
return super.visitFile(file, attrs)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
FileSystems.newFileSystem(remappedClientJar).use { consumer.accept(it) }
|
||||
FileSystems.newFileSystem(remappedServerJar).use { consumer.accept(it) }
|
||||
}
|
||||
|
||||
|
||||
projectData.targetNamespace = mcConf.targetNamespace
|
||||
|
||||
|
||||
RunConfigGenerator.generate(project)
|
||||
applyAW = AccessWidener.hasAW(project)
|
||||
}
|
||||
|
@ -77,29 +120,29 @@ abstract class PhytotelmaGradleExtensionImpl @Inject constructor(
|
|||
VersionChecker.getDependencies(project, version) {
|
||||
project.dependencies.add(Constants.MINECRAFT_CONFIGURATION, it)
|
||||
}
|
||||
project.dependencies.add(Constants.MINECRAFT_CONFIGURATION, "net.minecraft:client:$version:remapped")
|
||||
project.dependencies.add(Constants.MINECRAFT_CONFIGURATION, "net.minecraft:minecraft-merged:$version")
|
||||
|
||||
AssetDownloader.download(project)
|
||||
|
||||
if (applyAW) {
|
||||
project.afterEvaluate {
|
||||
println("Applying AccessWideners...")
|
||||
AccessWidener.apply(project, remappedJar)
|
||||
AccessWidener.apply(project, mergedJar)
|
||||
}
|
||||
}
|
||||
project.afterEvaluate {
|
||||
if (mcConf.targetNamespace != Constants.MOJMAP_NAMESPACE) {
|
||||
Thyroxine.remap(
|
||||
MappingData("", ""),
|
||||
remappedJar,
|
||||
remappedJar.resolveSibling(Constants.ALTERNATIVE_RUNTIME_JAR_NAME),
|
||||
mergedJar,
|
||||
mergedJar.resolveSibling(Constants.ALTERNATIVE_RUNTIME_JAR_NAME),
|
||||
false,
|
||||
listOf(RemappingStep { classVisitor, _ ->
|
||||
RuntimeAccessFixVisitor(classVisitor)
|
||||
})
|
||||
)
|
||||
} else {
|
||||
Files.deleteIfExists(remappedJar.resolveSibling(Constants.ALTERNATIVE_RUNTIME_JAR_NAME))
|
||||
Files.deleteIfExists(mergedJar.resolveSibling(Constants.ALTERNATIVE_RUNTIME_JAR_NAME))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import kotlin.io.path.readBytes
|
|||
class MixinAnnotationRemapper(
|
||||
cv: ClassVisitor,
|
||||
private val mapper: Remapper,
|
||||
private val mojmapGameJar: Path
|
||||
private vararg val contextJars: Path
|
||||
) : ClassRemapper(Constants.ASM_VERSION, cv, mapper) {
|
||||
|
||||
private var target: String? = null
|
||||
|
@ -80,9 +80,14 @@ class MixinAnnotationRemapper(
|
|||
override fun visitEnd() {
|
||||
if (target != null) {
|
||||
targetNode = ClassNode()
|
||||
FileSystems.newFileSystem(mojmapGameJar).use { fs ->
|
||||
fs.getPath("$target.class").takeIf { it.exists() }
|
||||
?.readBytes()?.let(::ClassReader).let { it?.accept(targetNode, 0) }
|
||||
for (gameJar in contextJars) {
|
||||
FileSystems.newFileSystem(gameJar).use { fs ->
|
||||
fs.getPath("$target.class").takeIf { it.exists() }
|
||||
?.readBytes()?.let(::ClassReader).let { it?.accept(targetNode, 0) }
|
||||
}
|
||||
if (targetNode != null) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
super.visitEnd()
|
||||
|
|
Loading…
Reference in a new issue