From 4f7bccd45653516e6eb4804c06304e1539dbb1ad Mon Sep 17 00:00:00 2001 From: glitch Date: Mon, 25 Sep 2023 11:02:46 -0500 Subject: [PATCH] Fix fabric loader being applied on accident --- fabric-loom | 2 +- ...abric-dependencies-replaced-by-Quilt.patch | 35 +++++++++++++------ patches/0003-Support-QMJ.patch | 20 +++++------ 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/fabric-loom b/fabric-loom index cfe72b9..ffc786d 160000 --- a/fabric-loom +++ b/fabric-loom @@ -1 +1 @@ -Subproject commit cfe72b933a35778fbac05628f7a5111b9219c6e0 +Subproject commit ffc786d3cd4b6835196a3f8945d01119fcd0ac16 diff --git a/patches/0002-Exclude-Fabric-dependencies-replaced-by-Quilt.patch b/patches/0002-Exclude-Fabric-dependencies-replaced-by-Quilt.patch index c091089..fd4de1e 100644 --- a/patches/0002-Exclude-Fabric-dependencies-replaced-by-Quilt.patch +++ b/patches/0002-Exclude-Fabric-dependencies-replaced-by-Quilt.patch @@ -52,7 +52,7 @@ index 7274912e12820e697991389626d5bda87ddd1162..2b95638caf9acc51353a994a24431a00 } diff --git a/src/main/java/net/fabricmc/loom/configuration/mods/ModConfigurationRemapper.java b/src/main/java/net/fabricmc/loom/configuration/mods/ModConfigurationRemapper.java -index 7ff0fbc78dc242a82a925ca72dd85168116aa115..cdb27fca02bae7b2f26864a90b69c812876f202d 100644 +index 7ff0fbc78dc242a82a925ca72dd85168116aa115..86316049c4c17f9362ab3a10cb25489d29a05229 100644 --- a/src/main/java/net/fabricmc/loom/configuration/mods/ModConfigurationRemapper.java +++ b/src/main/java/net/fabricmc/loom/configuration/mods/ModConfigurationRemapper.java @@ -31,12 +31,20 @@ import java.nio.file.Files; @@ -84,7 +84,7 @@ index 7ff0fbc78dc242a82a925ca72dd85168116aa115..cdb27fca02bae7b2f26864a90b69c812 import net.fabricmc.loom.configuration.providers.minecraft.MinecraftSourceSets; import net.fabricmc.loom.util.Checksum; import net.fabricmc.loom.util.Constants; -@@ -121,19 +128,19 @@ public class ModConfigurationRemapper { +@@ -121,19 +128,22 @@ public class ModConfigurationRemapper { } // Round 1: Discovery @@ -98,7 +98,10 @@ index 7ff0fbc78dc242a82a925ca72dd85168116aa115..cdb27fca02bae7b2f26864a90b69c812 final Map> dependenciesBySourceConfig = new HashMap<>(); + final Map> artifactsBySourceConfig = new HashMap<>(); + final Set sourceConfigsWithQsl = new HashSet<>(); -+ AtomicReference installer = new AtomicReference<>(); ++ // todo clean this up ++ AtomicReference installer = new AtomicReference<>(); ++ AtomicReference installerConfigToApply = new AtomicReference<>(); ++ AtomicReference installerArtifactToApply = new AtomicReference<>(); configsToRemap.forEach((sourceConfig, remappedConfig) -> { - /* - sourceConfig - The source configuration where the intermediary named artifacts come from. i.e "modApi" @@ -113,17 +116,17 @@ index 7ff0fbc78dc242a82a925ca72dd85168116aa115..cdb27fca02bae7b2f26864a90b69c812 final ArtifactMetadata artifactMetadata; try { -@@ -143,11 +150,13 @@ public class ModConfigurationRemapper { +@@ -143,21 +153,75 @@ public class ModConfigurationRemapper { } if (artifactMetadata.installerData() != null) { - if (extension.getInstallerData() != null) { - project.getLogger().info("Found another installer JSON in ({}), ignoring", artifact.path()); + if (installer.get() == null) { -+ installer.set(artifactMetadata.installerData()); -+ } else if (!installer.get().isQuilt() && artifactMetadata.installerData().isQuilt()) { ++ installer.set(artifactMetadata); ++ } else if (!installer.get().installerData().isQuilt() && artifactMetadata.installerData().isQuilt()) { + // Prefer Quilt over Fabric loader -+ installer.set(artifactMetadata.installerData()); ++ installer.set(artifactMetadata); } else { - project.getLogger().info("Applying installer data from {}", artifact.path()); - artifactMetadata.installerData().applyToProject(project); @@ -131,7 +134,15 @@ index 7ff0fbc78dc242a82a925ca72dd85168116aa115..cdb27fca02bae7b2f26864a90b69c812 } } -@@ -158,6 +167,49 @@ public class ModConfigurationRemapper { + if (!artifactMetadata.shouldRemap()) { ++ if (artifactMetadata.installerData() != null) { ++ installerConfigToApply.set(remappedConfig); ++ installerArtifactToApply.set(artifact); ++ continue; // we'll apply the installer later ++ } + // Note: not applying to any type of vanilla Gradle target config like + // api or implementation to fix https://github.com/FabricMC/fabric-loom/issues/572. + artifact.applyToConfiguration(project, remappedConfig); continue; } @@ -150,15 +161,19 @@ index 7ff0fbc78dc242a82a925ca72dd85168116aa115..cdb27fca02bae7b2f26864a90b69c812 + if (installer.get() != null) { + project.getLogger().info("Applying installer data"); + -+ if (installer.get().isQuilt()) { ++ if (installer.get().installerData().isQuilt()) { + quiltLoader = true; + } else { + quiltLoader = false; + project.getLogger().lifecycle("Warning: Quilt Loader not detected. Using Fabric Loader."); + } + -+ installer.get().applyToProject(project); ++ if (!installer.get().shouldRemap()) { ++ installerArtifactToApply.get().applyToConfiguration(project, installerConfigToApply.get()); ++ } ++ installer.get().installerData().applyToProject(project); + } else { ++ project.getLogger().lifecycle("Warning: No loader detected."); + quiltLoader = false; + } + diff --git a/patches/0003-Support-QMJ.patch b/patches/0003-Support-QMJ.patch index de4bcd5..3195111 100644 --- a/patches/0003-Support-QMJ.patch +++ b/patches/0003-Support-QMJ.patch @@ -675,7 +675,7 @@ index 2b95638caf9acc51353a994a24431a00e2f3c2ae..536f13bce74690e3a207bd33ec29853a if (Files.exists(manifestPath)) { diff --git a/src/main/java/net/fabricmc/loom/configuration/mods/ModConfigurationRemapper.java b/src/main/java/net/fabricmc/loom/configuration/mods/ModConfigurationRemapper.java -index cdb27fca02bae7b2f26864a90b69c812876f202d..ca00d3f012601baebbd944ea789eaeda20f87772 100644 +index 86316049c4c17f9362ab3a10cb25489d29a05229..04b0ede63d0f2058f0d84ac8db2ae5ed72512571 100644 --- a/src/main/java/net/fabricmc/loom/configuration/mods/ModConfigurationRemapper.java +++ b/src/main/java/net/fabricmc/loom/configuration/mods/ModConfigurationRemapper.java @@ -40,11 +40,6 @@ import java.util.concurrent.atomic.AtomicReference; @@ -701,14 +701,14 @@ index cdb27fca02bae7b2f26864a90b69c812876f202d..ca00d3f012601baebbd944ea789eaeda import net.fabricmc.loom.configuration.providers.minecraft.MinecraftSourceSets; import net.fabricmc.loom.util.Checksum; import net.fabricmc.loom.util.Constants; -@@ -182,14 +179,14 @@ public class ModConfigurationRemapper { +@@ -190,14 +187,14 @@ public class ModConfigurationRemapper { if (installer.get() != null) { project.getLogger().info("Applying installer data"); -- if (installer.get().isQuilt()) { +- if (installer.get().installerData().isQuilt()) { - quiltLoader = true; - } else { -+ if (installer.get().isQuilt()) { ++ if (installer.get().installerData().isQuilt()) { + quiltLoader = true; + } else { quiltLoader = false; @@ -716,12 +716,12 @@ index cdb27fca02bae7b2f26864a90b69c812876f202d..ca00d3f012601baebbd944ea789eaeda - } + } -- installer.get().applyToProject(project); -+ installer.get().applyToProject(project); - } else { - quiltLoader = false; - } -@@ -210,6 +207,7 @@ public class ModConfigurationRemapper { +- if (!installer.get().shouldRemap()) { ++ if (!installer.get().shouldRemap()) { + installerArtifactToApply.get().applyToConfiguration(project, installerConfigToApply.get()); + } + installer.get().installerData().applyToProject(project); +@@ -222,6 +219,7 @@ public class ModConfigurationRemapper { } else if (sourceConfigsWithQsl.contains(sourceConfig) && artifact.group().equals("net.fabricmc.fabric-api")) { continue; }