Skip to content

Commit

Permalink
Fix fabric loader being applied on accident
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGlitch76 committed Sep 25, 2023
1 parent 9259091 commit 4f7bccd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 21 deletions.
2 changes: 1 addition & 1 deletion fabric-loom
35 changes: 25 additions & 10 deletions patches/0002-Exclude-Fabric-dependencies-replaced-by-Quilt.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -98,7 +98,10 @@ index 7ff0fbc78dc242a82a925ca72dd85168116aa115..cdb27fca02bae7b2f26864a90b69c812
final Map<Configuration, List<ModDependency>> dependenciesBySourceConfig = new HashMap<>();
+ final Map<Configuration, List<ArtifactRef>> artifactsBySourceConfig = new HashMap<>();
+ final Set<Configuration> sourceConfigsWithQsl = new HashSet<>();
+ AtomicReference<InstallerData> installer = new AtomicReference<>();
+ // todo clean this up
+ AtomicReference<ArtifactMetadata> installer = new AtomicReference<>();
+ AtomicReference<Configuration> installerConfigToApply = new AtomicReference<>();
+ AtomicReference<ArtifactRef> installerArtifactToApply = new AtomicReference<>();
configsToRemap.forEach((sourceConfig, remappedConfig) -> {
- /*
- sourceConfig - The source configuration where the intermediary named artifacts come from. i.e "modApi"
Expand All @@ -113,25 +116,33 @@ 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);
+ project.getLogger().info("Found another installer JSON in ({}), ignoring", artifact.path());
}
}

@@ -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;
}

Expand All @@ -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;
+ }
+
Expand Down
20 changes: 10 additions & 10 deletions patches/0003-Support-QMJ.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -701,27 +701,27 @@ 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;
project.getLogger().lifecycle("Warning: Quilt Loader not detected. Using Fabric Loader.");
- }
+ }

- 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;
}
Expand Down

0 comments on commit 4f7bccd

Please sign in to comment.