Skip to content

Commit 8385acb

Browse files
committed
Support for Tiny v2 mappings
1 parent f8b2054 commit 8385acb

File tree

3 files changed

+17
-53
lines changed

3 files changed

+17
-53
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ dependencies {
4848
implementation(gradleApi())
4949
compile(localGroovy())
5050
implementation("com.github.replaymod:remap:19874df")
51-
implementation("net.fabricmc:tiny-mappings-parser:0.1.1.8")
51+
implementation("net.fabricmc:tiny-mappings-parser:0.2.1.13")
5252
}

src/main/kotlin/com/replaymod/gradle/preprocess/PreprocessPlugin.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.replaymod.gradle.preprocess
22

3-
import net.fabricmc.mappings.MappingsProvider
3+
import net.fabricmc.mapping.tree.TinyMappingFactory
44
import org.cadixdev.lorenz.io.MappingFormats
55
import org.gradle.api.GradleException
66
import org.gradle.api.Plugin
@@ -162,8 +162,8 @@ private fun Task.bakeNamedToIntermediaryMappings(mappings: Mappings, destination
162162
outputs.file(destination)
163163
doLast {
164164
val mapping = if (mappings.format == "tiny") {
165-
val tiny = mappings.file.inputStream().use { MappingsProvider.readTinyMappings(it) }
166-
TinyReader(tiny, "named", "intermediary", false).read()
165+
val tiny = mappings.file.inputStream().use { TinyMappingFactory.loadWithDetection(it.bufferedReader()) }
166+
TinyReader(tiny, "named", "intermediary").read()
167167
} else {
168168
MappingFormats.byId(mappings.format).read(mappings.file.toPath())
169169
}
@@ -179,8 +179,8 @@ private fun Task.bakeNamedToOfficialMappings(mappings: Mappings, namedToIntermed
179179
outputs.file(destination)
180180
doLast {
181181
val mapping = if (mappings.format == "tiny") {
182-
val tiny = mappings.file.inputStream().use { MappingsProvider.readTinyMappings(it) }
183-
TinyReader(tiny, "named", "official", false).read()
182+
val tiny = mappings.file.inputStream().use { TinyMappingFactory.loadWithDetection(it.bufferedReader()) }
183+
TinyReader(tiny, "named", "official").read()
184184
} else {
185185
val iMappings = namedToIntermediaryMappings!!
186186
val iMapSet = MappingFormats.byId(iMappings.format).read(iMappings.file.toPath())

src/main/kotlin/com/replaymod/gradle/preprocess/TinyReader.kt

Lines changed: 11 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,24 @@
1-
/*
2-
* Copyright (c) 2018, 2019 FabricMC
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
161
package com.replaymod.gradle.preprocess
172

18-
import net.fabricmc.mappings.Mappings
3+
import net.fabricmc.mapping.tree.TinyTree
194
import org.cadixdev.lorenz.MappingSet
205
import org.cadixdev.lorenz.io.MappingsReader
216
import java.io.IOException
227

23-
class TinyReader(private val m: Mappings, private val from: String, private val to: String, private val appendNone: Boolean) : MappingsReader() {
24-
25-
private fun procClassName(s: String): String {
26-
return if (appendNone) {
27-
if (s.indexOf('/') < 0) {
28-
"none/$s"
29-
} else {
30-
s
31-
}
32-
} else {
33-
s
34-
}
35-
}
36-
8+
class TinyReader(private val m: TinyTree, private val from: String, private val to: String) : MappingsReader() {
379
override fun read(mappings: MappingSet): MappingSet {
38-
for (entry in m.classEntries) {
39-
mappings.getOrCreateClassMapping(entry.get(from)).deobfuscatedName = procClassName(entry.get(to))
40-
}
10+
for (cls in m.classes) {
11+
val clsMapping = mappings.getOrCreateClassMapping(cls.getName(from))
12+
clsMapping.deobfuscatedName = cls.getName(to)
4113

42-
for (entry in m.fieldEntries) {
43-
val fromEntry = entry.get(from)
44-
val toEntry = entry.get(to)
45-
46-
mappings.getOrCreateClassMapping(fromEntry.owner)
47-
.getOrCreateFieldMapping(fromEntry.name, fromEntry.desc).deobfuscatedName = toEntry.name
48-
}
49-
50-
for (entry in m.methodEntries) {
51-
val fromEntry = entry.get(from)
52-
val toEntry = entry.get(to)
14+
for (field in cls.fields) {
15+
clsMapping.getOrCreateFieldMapping(field.getName(from), field.getDescriptor(from)).deobfuscatedName = field.getName(to)
16+
}
5317

54-
mappings.getOrCreateClassMapping(fromEntry.owner)
55-
.getOrCreateMethodMapping(fromEntry.name, fromEntry.desc).deobfuscatedName = toEntry.name
18+
for (method in cls.methods) {
19+
clsMapping.getOrCreateMethodMapping(method.getName(from), method.getDescriptor(from)).deobfuscatedName = method.getName(to)
20+
}
5621
}
57-
5822
return mappings
5923
}
6024

0 commit comments

Comments
 (0)