mirror of
https://github.com/architectury/architectury-plugin.git
synced 2026-03-27 19:57:00 -05:00
Fix refmap remapping not able to remap methods without class names
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
rootProject.name = 'architect-plugin'
|
||||
rootProject.name = 'architectury-plugin'
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ import org.objectweb.asm.tree.MethodInsnNode
|
||||
import org.zeroturnaround.zip.ZipUtil
|
||||
import java.io.*
|
||||
import java.net.URL
|
||||
import java.nio.file.FileSystemAlreadyExistsException
|
||||
import java.nio.file.FileSystems
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.util.*
|
||||
@@ -246,6 +248,7 @@ modId = "$fakeModId"
|
||||
private fun remapRefmap(obj: JsonObject) {
|
||||
val srg = project.extensions.getByType(LoomGradleExtension::class.java).mappingsProvider.mappingsWithSrg
|
||||
val methodPattern = "L(.*);(.*)(\\(.*)".toRegex()
|
||||
val methodPatternWithoutClass = "(.*)(\\(.*)".toRegex()
|
||||
val fieldPattern = "(.*):(.*)".toRegex()
|
||||
|
||||
obj.keySet().forEach { key ->
|
||||
@@ -253,6 +256,7 @@ modId = "$fakeModId"
|
||||
|
||||
val methodMatch = methodPattern.matchEntire(originalRef)
|
||||
val fieldMatch = fieldPattern.matchEntire(originalRef)
|
||||
val methodMatchWithoutClass = methodPatternWithoutClass.matchEntire(originalRef)
|
||||
|
||||
when {
|
||||
methodMatch != null -> {
|
||||
@@ -291,6 +295,21 @@ modId = "$fakeModId"
|
||||
})
|
||||
)
|
||||
}
|
||||
methodMatchWithoutClass != null -> {
|
||||
val replacementName: String = srg.classes.asSequence()
|
||||
.flatMap { it.methods.asSequence() }
|
||||
.filter { it.getName("intermediary") == methodMatchWithoutClass.groups[1]!!.value }
|
||||
.firstOrNull { it.getDescriptor("intermediary") == methodMatchWithoutClass.groups[2]!!.value }
|
||||
?.getName("srg") ?: methodMatchWithoutClass.groups[1]!!.value
|
||||
obj.addProperty(
|
||||
key, originalRef
|
||||
.replaceFirst(methodMatchWithoutClass.groups[1]!!.value, replacementName)
|
||||
.replaceFirst(methodMatchWithoutClass.groups[2]!!.value, methodMatchWithoutClass.groups[2]!!.value.remapDescriptor {
|
||||
srg.classes.firstOrNull { def -> def.getName("intermediary") == it }?.getName("srg")
|
||||
?: it
|
||||
})
|
||||
)
|
||||
}
|
||||
else -> logger.warn("Failed to remap refmap value: $originalRef")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user