mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 13:37:45 -05:00
Fix remapping forge dependencies
This commit is contained in:
@@ -175,7 +175,7 @@ public class MinecraftMappedProvider extends DependencyProvider {
|
||||
}
|
||||
|
||||
TinyTree yarnWithSrg = getExtension().getMappingsProvider().getMappingsWithSrg();
|
||||
AtRemapper.remap(output, yarnWithSrg);
|
||||
AtRemapper.remap(getProject().getLogger(), output, yarnWithSrg);
|
||||
CoreModClassRemapper.remapJar(output, yarnWithSrg, getProject().getLogger());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class ModCompileRemapper {
|
||||
String version = artifact.getModuleVersion().getId().getVersion();
|
||||
String classifierSuffix = artifact.getClassifier() == null ? "" : (":" + artifact.getClassifier());
|
||||
|
||||
if (!isFabricMod(logger, artifact)) {
|
||||
if (!shouldRemapMod(logger, artifact, extension.isForge())) {
|
||||
addToRegularCompile(project, regularConfig, artifact);
|
||||
continue;
|
||||
}
|
||||
@@ -112,13 +112,20 @@ public class ModCompileRemapper {
|
||||
/**
|
||||
* Checks if an artifact is a fabric mod, according to the presence of a fabric.mod.json.
|
||||
*/
|
||||
private static boolean isFabricMod(Logger logger, ResolvedArtifact artifact) {
|
||||
private static boolean shouldRemapMod(Logger logger, ResolvedArtifact artifact, boolean forge) {
|
||||
File input = artifact.getFile();
|
||||
|
||||
try (ZipFile zipFile = new ZipFile(input)) {
|
||||
if (zipFile.getEntry("fabric.mod.json") != null) {
|
||||
logger.info("Found Fabric mod in modCompile: {}", artifact.getId());
|
||||
return true;
|
||||
if (forge) {
|
||||
if (zipFile.getEntry("META-INF/mods.toml") != null) {
|
||||
logger.info("Found Forge mod in modCompile: {}", artifact.getId());
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (zipFile.getEntry("fabric.mod.json") != null) {
|
||||
logger.info("Found Fabric mod in modCompile: {}", artifact.getId());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -100,6 +100,7 @@ public class ModProcessor {
|
||||
}
|
||||
|
||||
private static void stripNestedJars(File file) {
|
||||
if (!ZipUtil.containsEntry(file, "fabric.mod.json")) return;
|
||||
// Strip out all contained jar info as we dont want loader to try and load the jars contained in dev.
|
||||
ZipUtil.transformEntries(file, new ZipEntryTransformerEntry[] {(new ZipEntryTransformerEntry("fabric.mod.json", new StringZipEntryTransformer() {
|
||||
@Override
|
||||
@@ -203,7 +204,7 @@ public class ModProcessor {
|
||||
}
|
||||
|
||||
if (extension.isForge()) {
|
||||
AtRemapper.remap(info.getRemappedOutput().toPath(), mappings);
|
||||
AtRemapper.remap(project.getLogger(), info.getRemappedOutput().toPath(), mappings);
|
||||
CoreModClassRemapper.remapJar(info.getRemappedOutput().toPath(), mappings, project.getLogger());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.fabricmc.loom.util.function.CollectionUtil;
|
||||
import net.fabricmc.mapping.tree.TinyTree;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.gradle.api.logging.Logger;
|
||||
|
||||
/**
|
||||
* Remaps AT classes from SRG to Yarn.
|
||||
@@ -44,7 +46,7 @@ import net.fabricmc.mapping.tree.TinyTree;
|
||||
* @author Juuz
|
||||
*/
|
||||
public final class AtRemapper {
|
||||
public static void remap(Path jar, TinyTree mappings) throws IOException {
|
||||
public static void remap(Logger logger, Path jar, TinyTree mappings) throws IOException {
|
||||
try (FileSystem fs = FileSystems.newFileSystem(URI.create("jar:" + jar.toUri()), ImmutableMap.of("create", false))) {
|
||||
Path atPath = fs.getPath("META-INF", "accesstransformer.cfg");
|
||||
|
||||
@@ -55,12 +57,17 @@ public final class AtRemapper {
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
String line = lines.get(i).trim();
|
||||
|
||||
if (line.startsWith("#")) {
|
||||
if (line.startsWith("#") || StringUtils.isBlank(line)) {
|
||||
output.add(i, line);
|
||||
continue;
|
||||
}
|
||||
|
||||
String[] parts = line.split(" ");
|
||||
if (parts.length < 3) {
|
||||
logger.warn("Invalid AT Line: " + line);
|
||||
output.add(i, line);
|
||||
continue;
|
||||
}
|
||||
String name = parts[1].replace('.', '/');
|
||||
parts[1] = CollectionUtil.find(
|
||||
mappings.getClasses(),
|
||||
|
||||
Reference in New Issue
Block a user