Force forge mod detection

This commit is contained in:
shedaniel
2021-01-08 09:58:05 +08:00
parent 0e64ffa086
commit 16e5b39eba

View File

@@ -73,7 +73,7 @@ public class ModCompileRemapper {
String version = artifact.getModuleVersion().getId().getVersion();
String classifierSuffix = artifact.getClassifier() == null ? "" : (":" + artifact.getClassifier());
if (!shouldRemapMod(logger, artifact, extension.isForge())) {
if (!shouldRemapMod(logger, artifact, extension.isForge(), sourceConfig.getName())) {
addToRegularCompile(project, regularConfig, artifact);
continue;
}
@@ -88,7 +88,7 @@ public class ModCompileRemapper {
modDependencies.add(info);
String remappedLog = group + ":" + name + ":" + version + classifierSuffix + " (" + mappingsSuffix + ")";
String remappedLog = group + ":" + name + ":" + version + classifierSuffix + " (" + mappingsSuffix + ")" + (info.requiresRemapping() ? " requires remapping" : " already remapped in " + info.getRemappedOutput().getAbsolutePath());
project.getLogger().info(":providing " + remappedLog);
if (sources != null) {
@@ -104,6 +104,7 @@ public class ModCompileRemapper {
// Add all of the remapped mods onto the config
for (ModDependencyInfo info : modDependencies) {
project.getLogger().info(":adding " + info.toString() + " into " + info.targetConfig.getName());
project.getDependencies().add(info.targetConfig.getName(), project.getDependencies().module(info.getRemappedNotation()));
}
}
@@ -112,18 +113,20 @@ public class ModCompileRemapper {
/**
* Checks if an artifact is a fabric mod, according to the presence of a fabric.mod.json.
*/
private static boolean shouldRemapMod(Logger logger, ResolvedArtifact artifact, boolean forge) {
private static boolean shouldRemapMod(Logger logger, ResolvedArtifact artifact, boolean forge, String config) {
File input = artifact.getFile();
try (ZipFile zipFile = new ZipFile(input)) {
if (forge) {
if (zipFile.getEntry("META-INF/mods.toml") != null) {
logger.info("Found Forge mod in modCompile: {}", artifact.getId());
logger.info("Found Forge mod in " + config + ": {}", artifact.getId());
return true;
}
logger.lifecycle(":could not find forge mod in " + config + " but forcing: {}", artifact.getId());
return true;
} else {
if (zipFile.getEntry("fabric.mod.json") != null) {
logger.info("Found Fabric mod in modCompile: {}", artifact.getId());
logger.info("Found Fabric mod in " + config + ": {}", artifact.getId());
return true;
}
}