@@ -8,6 +8,7 @@ import kotlinx.serialization.json.jsonObject
8
8
import kotlinx.serialization.json.jsonPrimitive
9
9
import me.shedaniel.linkie.MappingsBuilder
10
10
import me.shedaniel.linkie.MappingsSource
11
+ import me.shedaniel.linkie.MethodArg
11
12
import me.shedaniel.linkie.Namespace
12
13
import me.shedaniel.linkie.parser.apply
13
14
import me.shedaniel.linkie.parser.srg
@@ -29,13 +30,15 @@ object MCPNamespace : Namespace("mcp") {
29
30
30
31
buildMappings(name = " MCP" ) {
31
32
val latestSnapshot = mcpConfigSnapshots[it.toVersion()]?.maxOrNull()!!
32
- source(if (it.toVersion() >= Version (1 , 13 )) {
33
- loadTsrgFromURLZip(URL (" https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp_config/$it /mcp_config-$it .zip" ))
34
- MappingsSource .MCP_TSRG
35
- } else {
36
- loadSrgFromURLZip(URL (" https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp/$it /mcp-$it -srg.zip" ))
37
- MappingsSource .MCP_SRG
38
- })
33
+ source(
34
+ if (it.toVersion() >= Version (1 , 13 )) {
35
+ loadTsrgFromURLZip(URL (" https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp_config/$it /mcp_config-$it .zip" ))
36
+ MappingsSource .MCP_TSRG
37
+ } else {
38
+ loadSrgFromURLZip(URL (" https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp/$it /mcp-$it -srg.zip" ))
39
+ MappingsSource .MCP_SRG
40
+ }
41
+ )
39
42
loadMCPFromURLZip(URL (" https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp_snapshot/$latestSnapshot -$it /mcp_snapshot-$latestSnapshot -$it .zip" ))
40
43
}
41
44
}
@@ -95,14 +98,16 @@ object MCPNamespace : Namespace("mcp") {
95
98
}
96
99
97
100
private fun MappingsBuilder.loadSrgFromInputStream (content : String ) {
98
- apply (srg(content),
101
+ apply (
102
+ srg(content),
99
103
obfMerged = " obf" ,
100
104
intermediary = " srg" ,
101
105
)
102
106
}
103
107
104
108
private fun MappingsBuilder.loadTsrgFromInputStream (content : String ) {
105
- apply (tsrg(content),
109
+ apply (
110
+ tsrg(content),
106
111
obfMerged = " obf" ,
107
112
intermediary = " srg" ,
108
113
)
@@ -114,6 +119,7 @@ object MCPNamespace : Namespace("mcp") {
114
119
when (path.split(" /" ).lastOrNull()) {
115
120
" fields.csv" -> loadMCPFieldsCSVFromInputStream(entry.bytes.lines())
116
121
" methods.csv" -> loadMCPMethodsCSVFromInputStream(entry.bytes.lines())
122
+ " params.csv" -> loadMCPParamsCSVFromInputStream(entry.bytes.lines())
117
123
}
118
124
}
119
125
}
@@ -149,6 +155,27 @@ object MCPNamespace : Namespace("mcp") {
149
155
}
150
156
}
151
157
158
+ private fun MappingsBuilder.loadMCPParamsCSVFromInputStream (lines : Sequence <String >) {
159
+ val map = mutableMapOf<String , MutableList <MethodArg >>()
160
+ val paramRegex = """ p_(\d+)_(\d+)_?""" .toRegex()
161
+ val funcRegex = """ func_(\d+)_([^_]+)_?""" .toRegex()
162
+ lines.filterNotBlank().forEach {
163
+ val split = it.split(' ,' )
164
+ val match = paramRegex.matchEntire(split[0 ]) ? : return @forEach
165
+ map.getOrPut(match.groups[1 ]!! .value) { mutableListOf () }
166
+ .add(MethodArg (match.groups[2 ]!! .value.toInt(), split[1 ]))
167
+ }
168
+ container.classes.forEach { (_, it) ->
169
+ it.methods.forEach inner@{ method ->
170
+ val match = funcRegex.matchEntire(method.intermediaryName) ? : return @inner
171
+ map[match.groups[1 ]!! .value]?.apply {
172
+ if (method.args == null ) method.args = mutableListOf ()
173
+ method.args!! .addAll(this )
174
+ }
175
+ }
176
+ }
177
+ }
178
+
152
179
@Serializable
153
180
data class MCPVersion (
154
181
val name : String ,
0 commit comments