@@ -20,13 +20,15 @@ import org.cadixdev.lorenz.io.srg.tsrg.TSrgReader
20
20
import org.cadixdev.lorenz.io.srg.tsrg.TSrgWriter
21
21
import org.cadixdev.lorenz.model.ClassMapping
22
22
import org.cadixdev.lorenz.model.FieldMapping
23
+ import org.cadixdev.lorenz.model.Mapping
23
24
import org.gradle.api.Project
24
25
import org.gradle.api.tasks.Input
25
26
import org.gradle.api.tasks.InputDirectory
26
27
import org.gradle.api.tasks.InputFile
27
28
import org.gradle.api.tasks.OutputDirectory
28
29
import org.objectweb.asm.Type
29
30
31
+ import java.util.jar.JarFile
30
32
import java.util.stream.Collectors
31
33
32
34
class ProcessMappingTask implements Runnable {
@@ -76,7 +78,7 @@ class ProcessMappingTask implements Runnable {
76
78
}
77
79
super . writeClassMapping(mapping)
78
80
}
79
- }. write(new TinyMappingsReader (tree, " srg " , " named " ) . read ())
81
+ }. write(mcp . reverse ())
80
82
}
81
83
82
84
def srg = MappingSet . create()
@@ -97,11 +99,22 @@ class ProcessMappingTask implements Runnable {
97
99
98
100
def im = new InheritanceMap ()
99
101
def classes = [] as ArrayList<String >
100
- csrg. topLevelClassMappings. each {
102
+ /* csrg.topLevelClassMappings.each {
101
103
classes.add(it.fullDeobfuscatedName)
102
104
it.innerClassMappings.each {
103
105
classes.add(it.fullDeobfuscatedName)
104
106
}
107
+ }*/
108
+ def jarFile = new JarFile (this . inJar)
109
+ for (entry in jarFile. entries()) {
110
+ var name = entry. name
111
+ if (name. startsWith(" net" ) && name. endsWith(' .class' )) {
112
+ var internalName = name. substring(0 , name. lastIndexOf(' .' ))
113
+ // if (internalName.split('\\$').any { it.integer }) {
114
+ // continue
115
+ // }
116
+ classes. add(internalName)
117
+ }
105
118
}
106
119
im. generate(new JarProvider (Jar . init(this . inJar)), classes)
107
120
new File (outDir, ' inheritanceMap.txt' ). withWriter { w ->
@@ -138,7 +151,14 @@ class ProcessMappingTask implements Runnable {
138
151
if (! mapping. hasMappings()) {
139
152
this . writer. println (String . format(" %s %s" , mapping. getFullObfuscatedName(), mapping. getFullDeobfuscatedName()));
140
153
} else if (mapping. fullObfuscatedName. contains(' /' )) {
141
- super . writeClassMapping(mapping)
154
+ // hasDeobfuscatedName() has to be true for every mapping
155
+ // since we need to preserve identity() mapping
156
+ // Or else SpecialSource recognize classes not in mapping as not mapped
157
+ this . writer. println (String . format(" %s %s" , mapping. getFullObfuscatedName(), mapping. getFullDeobfuscatedName()));
158
+
159
+ mapping. getFieldsByName(). values(). stream(). filter(Mapping ::hasDeobfuscatedName). sorted(this . getConfig(). getFieldMappingComparator()). forEach(this ::writeFieldMapping);
160
+ mapping. getMethodMappings(). stream(). filter(Mapping ::hasDeobfuscatedName). sorted(this . getConfig(). getMethodMappingComparator()). forEach(this ::writeMethodMapping);
161
+ mapping. getInnerClassMappings(). stream(). filter(ClassMapping ::hasMappings). sorted(this . getConfig(). getClassMappingComparator()). forEach(this ::writeClassMapping);
142
162
}
143
163
}
144
164
@@ -167,7 +187,13 @@ class ProcessMappingTask implements Runnable {
167
187
if (! mapping. hasMappings()) {
168
188
this . writer. println (String . format(" %s %s" , mapping. getFullObfuscatedName(), mapping. getFullDeobfuscatedName()));
169
189
} else if (mapping. fullObfuscatedName. contains(' /' )) {
170
- super . writeClassMapping(mapping)
190
+ // hasDeobfuscatedName() has to be true for every mapping
191
+ // since we need to preserve identity() mapping
192
+ // Or else SpecialSource recognize classes not in mapping as not mapped
193
+ this . writer. println (String . format(" %s %s" , mapping. getFullObfuscatedName(), mapping. getFullDeobfuscatedName()));
194
+ mapping. getFieldsByName(). values(). stream(). filter(Mapping ::hasDeobfuscatedName). sorted(this . getConfig(). getFieldMappingComparator()). forEach(this ::writeFieldMapping);
195
+ mapping. getMethodMappings(). stream(). filter(Mapping ::hasDeobfuscatedName). sorted(this . getConfig(). getMethodMappingComparator()). forEach(this ::writeMethodMapping);
196
+ mapping. getInnerClassMappings(). stream(). filter(ClassMapping ::hasMappings). sorted(this . getConfig(). getClassMappingComparator()). forEach(this ::writeClassMapping);
171
197
}
172
198
}
173
199
@@ -196,7 +222,13 @@ class ProcessMappingTask implements Runnable {
196
222
if (! mapping. hasMappings()) {
197
223
this . writer. println (String . format(" %s %s" , mapping. getFullObfuscatedName(), mapping. getFullDeobfuscatedName()));
198
224
} else if (mapping. fullObfuscatedName. contains(' /' )) {
199
- super . writeClassMapping(mapping)
225
+ // hasDeobfuscatedName() has to be true for every mapping
226
+ // since we need to preserve identity() mapping
227
+ // Or else SpecialSource recognize classes not in mapping as not mapped
228
+ this . writer. println (String . format(" %s %s" , mapping. getFullObfuscatedName(), mapping. getFullDeobfuscatedName()));
229
+ mapping. getFieldsByName(). values(). stream(). filter(Mapping ::hasDeobfuscatedName). sorted(this . getConfig(). getFieldMappingComparator()). forEach(this ::writeFieldMapping);
230
+ mapping. getMethodMappings(). stream(). filter(Mapping ::hasDeobfuscatedName). sorted(this . getConfig(). getMethodMappingComparator()). forEach(this ::writeMethodMapping);
231
+ mapping. getInnerClassMappings(). stream(). filter(ClassMapping ::hasMappings). sorted(this . getConfig(). getClassMappingComparator()). forEach(this ::writeClassMapping);
200
232
}
201
233
}
202
234
0 commit comments