mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 21:47:42 -05:00
Switch back to Atlas
This commit is contained in:
@@ -25,46 +25,22 @@
|
||||
package net.fabricmc.loom.providers;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.net.URI;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import cuchaz.enigma.command.ConvertMappingsCommand;
|
||||
import cuchaz.enigma.command.InvertMappingsCommand;
|
||||
import org.cadixdev.lorenz.MappingSet;
|
||||
import org.cadixdev.lorenz.io.enigma.EnigmaWriter;
|
||||
import org.cadixdev.lorenz.io.srg.tsrg.TSrgReader;
|
||||
import org.cadixdev.lorenz.model.ClassMapping;
|
||||
import org.cadixdev.lorenz.model.FieldMapping;
|
||||
import org.cadixdev.lorenz.model.MethodMapping;
|
||||
import org.cadixdev.lorenz.model.TopLevelClassMapping;
|
||||
import org.gradle.api.Project;
|
||||
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.DependencyProvider;
|
||||
import net.fabricmc.mapping.tree.ClassDef;
|
||||
import net.fabricmc.stitch.commands.CommandReorderTiny;
|
||||
import net.fabricmc.stitch.commands.tinyv2.CommandReorderTinyV2;
|
||||
import net.fabricmc.stitch.commands.tinyv2.TinyClass;
|
||||
import net.fabricmc.stitch.commands.tinyv2.TinyField;
|
||||
import net.fabricmc.stitch.commands.tinyv2.TinyMethod;
|
||||
|
||||
public class McpConfigProvider extends DependencyProvider {
|
||||
private File mcp;
|
||||
private File srg;
|
||||
private File srgTiny;
|
||||
private File invertedSrgTiny;
|
||||
|
||||
public McpConfigProvider(Project project) {
|
||||
super(project);
|
||||
@@ -74,7 +50,7 @@ public class McpConfigProvider extends DependencyProvider {
|
||||
public void provide(DependencyInfo dependency, Consumer<Runnable> postPopulationScheduler) throws Exception {
|
||||
init(dependency.getDependency().getVersion());
|
||||
|
||||
if (mcp.exists() && srg.exists() && srgTiny.exists() && invertedSrgTiny.exists()) {
|
||||
if (mcp.exists() && srg.exists()) {
|
||||
return; // No work for us to do here
|
||||
}
|
||||
|
||||
@@ -89,43 +65,11 @@ public class McpConfigProvider extends DependencyProvider {
|
||||
Files.copy(fs.getPath("config", "joined.tsrg"), srg.toPath());
|
||||
}
|
||||
}
|
||||
|
||||
if (!srgTiny.exists()) {
|
||||
List<TinyClass> classes = new ArrayList<>();
|
||||
|
||||
try (TSrgReader reader = new TSrgReader(new FileReader(srg))) {
|
||||
MappingSet mappings = reader.read();
|
||||
|
||||
}
|
||||
|
||||
new ConvertMappingsCommand().run("enigma_file", enigma.toString(), "tinyv2:official:srg", srgTiny.getAbsolutePath());
|
||||
new CommandReorderTinyV2().run(new String[]{srgTiny.getAbsolutePath(), invertedSrgTiny.getAbsolutePath(), "srg", "official"});
|
||||
}
|
||||
}
|
||||
|
||||
private <M extends ClassMapping<M, ?>> TinyClass toTinyClass(M mapping) {
|
||||
List<String> names = ImmutableList.of(mapping.getFullObfuscatedName(), mapping.getFullDeobfuscatedName());
|
||||
List<TinyMethod> methods = new ArrayList<>();
|
||||
List<TinyField> fields = new ArrayList<>();
|
||||
|
||||
for (MethodMapping method : mapping.getMethodMappings()) {
|
||||
List<String> methodNames = ImmutableList.of(method.getObfuscatedName(), method.getDeobfuscatedName());
|
||||
methods.add(new TinyMethod(method.getObfuscatedDescriptor(), methodNames, Collections.emptySet(), Collections.emptySet(), Collections.emptySet()));
|
||||
}
|
||||
|
||||
for (FieldMapping field : mapping.getFieldMappings()) {
|
||||
List<String> fieldNames = ImmutableList.of(field.getObfuscatedName(), field.getDeobfuscatedName());
|
||||
fields.add(new TinyField(field.get))
|
||||
}
|
||||
|
||||
return new TinyClass(names, methods, fields, Collections.emptySet());
|
||||
}
|
||||
|
||||
private void init(String version) {
|
||||
mcp = new File(getExtension().getUserCache(), "mcp-" + version + ".zip");
|
||||
srg = new File(getExtension().getUserCache(), "srg-" + version + ".tsrg");
|
||||
srgTiny = new File(getExtension().getUserCache(), "srg-" + version + ".tiny");
|
||||
invertedSrgTiny = new File(getExtension().getUserCache(), "srg-" + version + "-inverted.tiny");
|
||||
}
|
||||
|
||||
public File getMcp() {
|
||||
@@ -136,14 +80,6 @@ public class McpConfigProvider extends DependencyProvider {
|
||||
return srg;
|
||||
}
|
||||
|
||||
public File getSrgTiny() {
|
||||
return srgTiny;
|
||||
}
|
||||
|
||||
public File getInvertedSrgTiny() {
|
||||
return invertedSrgTiny;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetConfig() {
|
||||
return Constants.MCP_CONFIG;
|
||||
|
||||
Reference in New Issue
Block a user