Update lorenz-tiny to 2.0.0

dev/0.11
modmuss50 2020-05-27 16:41:43 +01:00
parent 2645fef789
commit 5ae727612d
3 changed files with 10 additions and 44 deletions

View File

@ -51,7 +51,7 @@ dependencies {
transitive = false
}
implementation ('net.fabricmc:lorenz-tiny:1.0.0+build.1') {
implementation ('net.fabricmc:lorenz-tiny:2.0.0+build.2') {
transitive = false
}

View File

@ -49,7 +49,7 @@ import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.providers.MappingsProvider;
import net.fabricmc.loom.providers.MinecraftMappedProvider;
import net.fabricmc.loom.util.SourceRemapper;
import net.fabricmc.lorenztiny.LorenzTiny;
import net.fabricmc.lorenztiny.TinyMappingsJoiner;
import net.fabricmc.mapping.tree.TinyMappingFactory;
import net.fabricmc.mapping.tree.TinyTree;
@ -149,8 +149,12 @@ public class MigrateMappingsTask extends AbstractLoomTask {
Path inputDir, Path outputDir, TinyTree currentMappings, TinyTree targetMappings
) throws IOException {
project.getLogger().lifecycle(":joining mappings");
MappingSet mappingSet = LorenzTiny.readMappings(currentMappings, targetMappings,
"intermediary", "named").read();
MappingSet mappingSet = new TinyMappingsJoiner(
currentMappings, "named",
targetMappings, "named",
"intermediary"
).read();
project.getLogger().lifecycle(":remapping");
Mercury mercury = SourceRemapper.createMercuryWithClassPath(project, false);

View File

@ -32,8 +32,6 @@ import java.util.ArrayList;
import java.util.List;
import org.cadixdev.lorenz.MappingSet;
import org.cadixdev.lorenz.io.MappingsReader;
import org.cadixdev.lorenz.model.ClassMapping;
import org.cadixdev.mercury.Mercury;
import org.cadixdev.mercury.remapper.MercuryRemapper;
import org.gradle.api.Project;
@ -41,9 +39,7 @@ import org.zeroturnaround.zip.ZipUtil;
import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.providers.MappingsProvider;
import net.fabricmc.mapping.tree.ClassDef;
import net.fabricmc.mapping.tree.FieldDef;
import net.fabricmc.mapping.tree.MethodDef;
import net.fabricmc.lorenztiny.TinyMappingsReader;
import net.fabricmc.mapping.tree.TinyTree;
import net.fabricmc.stitch.util.StitchUtil;
@ -151,7 +147,7 @@ public class SourceRemapper {
try {
TinyTree m = mappingsProvider.getMappings();
project.getLogger().lifecycle(":loading " + (toNamed ? "intermediary -> named" : "named -> intermediary") + " source mappings");
return new TinyReader(m, toNamed ? "intermediary" : "named", toNamed ? "named" : "intermediary").read();
return new TinyMappingsReader(m, toNamed ? "intermediary" : "named", toNamed ? "named" : "intermediary").read();
} catch (Exception e) {
throw new RuntimeException(e);
}
@ -213,38 +209,4 @@ public class SourceRemapper {
// ".java" is not a valid java file
return name.endsWith(".java") && name.length() != 5;
}
public static class TinyReader extends MappingsReader {
private final TinyTree mappings;
private final String from, to;
public TinyReader(TinyTree m, String from, String to) {
this.mappings = m;
this.from = from;
this.to = to;
}
@Override
public MappingSet read(final MappingSet mappings) {
for (ClassDef classDef : this.mappings.getClasses()) {
ClassMapping classMapping = mappings.getOrCreateClassMapping(classDef.getName(from))
.setDeobfuscatedName(classDef.getName(to));
for (FieldDef field : classDef.getFields()) {
classMapping.getOrCreateFieldMapping(field.getName(from), field.getDescriptor(from))
.setDeobfuscatedName(field.getName(to));
}
for (MethodDef method : classDef.getMethods()) {
classMapping.getOrCreateMethodMapping(method.getName(from), method.getDescriptor(from))
.setDeobfuscatedName(method.getName(to));
}
}
return mappings;
}
@Override
public void close() { }
}
}