feat: support NeoForge loader for Modrinth and MultiMC import

This commit is contained in:
Ryan Dowling 2023-08-13 22:39:10 +10:00
parent 74005bdbe9
commit 3ea69265b8
No known key found for this signature in database
GPG key ID: 5539FCDB88950EFD
6 changed files with 83 additions and 9 deletions

View file

@ -6,11 +6,11 @@ This changelog only contains the changes that are unreleased. For changes for in
## 3.4.31.3
### New Features
- Servers will now be started using kitty, allacritty or gnome-terminal, if x-terminal-emulator or exo-open aren't present
- Rename "Vanilla Packs" to "Create Pack"
- Support NeoForge loader for Modrinth and MultiMC import
### Fixes
### Misc
- Organize ViewModels
- Rename "Vanilla Packs" to "Create Pack"

View file

@ -1798,7 +1798,7 @@ public class Instance extends MinecraftVersion {
manifest.components.add(minecraftComponent);
// fabric loader
if (launcher.loaderVersion.type.equals("Fabric") || launcher.loaderVersion.type.equals("LegacyFabric")) {
if (launcher.loaderVersion.isFabric() || launcher.loaderVersion.isLegacyFabric()) {
// mappings
MultiMCComponent fabricMappingsComponent = new MultiMCComponent();
fabricMappingsComponent.cachedName = "Intermediary Mappings";
@ -1832,7 +1832,25 @@ public class Instance extends MinecraftVersion {
}
// forge loader
if (launcher.loaderVersion.type.equals("Forge")) {
if (launcher.loaderVersion.isNeoForge()) {
// loader
MultiMCComponent forgeMappingsComponent = new MultiMCComponent();
forgeMappingsComponent.cachedName = "Forge";
forgeMappingsComponent.cachedRequires = new ArrayList<>();
MultiMCRequire minecraftRequire = new MultiMCRequire();
minecraftRequire.equals = id;
minecraftRequire.uid = "net.minecraft";
forgeMappingsComponent.cachedRequires.add(minecraftRequire);
forgeMappingsComponent.cachedVersion = launcher.loaderVersion.version;
forgeMappingsComponent.uid = "net.neoforged";
forgeMappingsComponent.version = launcher.loaderVersion.version;
manifest.components.add(forgeMappingsComponent);
}
// forge loader
if (launcher.loaderVersion.isForge()) {
// loader
MultiMCComponent forgeMappingsComponent = new MultiMCComponent();
forgeMappingsComponent.cachedName = "Forge";
@ -1850,7 +1868,7 @@ public class Instance extends MinecraftVersion {
}
// quilt loader
if (launcher.loaderVersion.type.equals("Quilt")) {
if (launcher.loaderVersion.isQuilt()) {
String hashedName = "org.quiltmc.hashed";
String cachedName = "Hashed Mappings";
if (ConfigManager.getConfigItem("loaders.quilt.switchHashedForIntermediary", true) == false) {

View file

@ -128,6 +128,10 @@ public class LoaderVersion {
return "quilt-loader";
}
if (this.isNeoForge()) {
return "neoforge";
}
return "forge";
}

View file

@ -776,6 +776,7 @@ public class InstanceInstallerDialog extends JDialog {
packVersion.hasLoader = modrinthManifest.dependencies.containsKey("fabric-loader")
|| modrinthManifest.dependencies.containsKey("quilt-loader")
|| modrinthManifest.dependencies.containsKey("neoforge")
|| modrinthManifest.dependencies.containsKey("forge");
pack.versions = Collections.singletonList(packVersion);
@ -812,7 +813,8 @@ public class InstanceInstallerDialog extends JDialog {
}
packVersion.hasLoader = multiMCManifest.components.stream()
.anyMatch(c -> c.uid.equalsIgnoreCase("net.minecraftforge")
.anyMatch(c -> c.uid.equalsIgnoreCase("net.neoforged")
|| c.uid.equalsIgnoreCase("net.minecraftforge")
|| c.uid.equalsIgnoreCase("net.fabricmc.hashed"));
pack.versions = Collections.singletonList(packVersion);

View file

@ -117,6 +117,7 @@ import com.atlauncher.data.technic.TechnicModpackAsset;
import com.atlauncher.data.technic.TechnicSolderModpackManifest;
import com.atlauncher.exceptions.LocalException;
import com.atlauncher.graphql.GetForgeLoaderVersionQuery;
import com.atlauncher.graphql.GetNeoForgeLoaderVersionQuery;
import com.atlauncher.gui.dialogs.BrowserDownloadDialog;
import com.atlauncher.interfaces.NetworkProgressable;
import com.atlauncher.managers.ConfigManager;
@ -1620,6 +1621,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
if (modrinthManifest.dependencies.containsKey("fabric-loader")
|| modrinthManifest.dependencies.containsKey("quilt-loader")
|| modrinthManifest.dependencies.containsKey("neoforge")
|| modrinthManifest.dependencies.containsKey("forge")) {
packVersion.loader = new com.atlauncher.data.json.Loader();
@ -1641,6 +1643,29 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
loaderMeta.put("loader", modrinthManifest.dependencies.get("quilt-loader"));
packVersion.loader.metadata = loaderMeta;
packVersion.loader.className = "com.atlauncher.data.minecraft.loaders.quilt.QuiltLoader";
} else if (modrinthManifest.dependencies.containsKey("neoforge")) {
String neoForgeVersionString = modrinthManifest.dependencies.get("neoforge");
if (ConfigManager.getConfigItem("useGraphql.loaderVersions", false) == false) {
throw new Exception(
"Failed to find loader version for " + neoForgeVersionString + " as GraphQL is disabled");
}
GetNeoForgeLoaderVersionQuery.Data response = GraphqlClient
.callAndWait(new GetNeoForgeLoaderVersionQuery(neoForgeVersionString));
if (response == null || response.neoForgeVersion() == null) {
throw new Exception("Failed to find loader version for " + neoForgeVersionString);
}
Map<String, Object> loaderMeta = new HashMap<>();
loaderMeta.put("minecraft", packVersion.minecraft);
loaderMeta.put("version", response.neoForgeVersion().version());
loaderMeta.put("rawVersion", response.neoForgeVersion().rawVersion());
packVersion.loader.metadata = loaderMeta;
packVersion.loader.className = "com.atlauncher.data.minecraft.loaders.neoforge.NeoForgeLoader";
} else if (modrinthManifest.dependencies.containsKey("forge")) {
String forgeVersionString = modrinthManifest.dependencies.get("forge");
@ -1756,6 +1781,8 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
packVersion.loader = new com.atlauncher.data.json.Loader();
MultiMCComponent neoForgedComponent = multiMCManifest.components.stream()
.filter(c -> c.uid.equalsIgnoreCase("net.neoforged")).findFirst().orElse(null);
MultiMCComponent forgeComponent = multiMCManifest.components.stream()
.filter(c -> c.uid.equalsIgnoreCase("net.minecraftforge")).findFirst().orElse(null);
MultiMCComponent fabricLoaderComponent = multiMCManifest.components.stream()
@ -1763,7 +1790,30 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
MultiMCComponent quiltLoaderComponent = multiMCManifest.components.stream()
.filter(c -> c.uid.equalsIgnoreCase("org.quiltmc.quilt-loader")).findFirst().orElse(null);
if (forgeComponent != null) {
if (neoForgedComponent != null) {
String neoForgeVersionString = neoForgedComponent.version;
if (ConfigManager.getConfigItem("useGraphql.loaderVersions", false) == false) {
throw new Exception(
"Failed to find loader version for " + neoForgeVersionString + " as GraphQL is disabled");
}
GetNeoForgeLoaderVersionQuery.Data response = GraphqlClient
.callAndWait(new GetNeoForgeLoaderVersionQuery(neoForgeVersionString));
if (response == null || response.neoForgeVersion() == null) {
throw new Exception("Failed to find loader version for " + neoForgeVersionString);
}
Map<String, Object> loaderMeta = new HashMap<>();
loaderMeta.put("minecraft", minecraftVersion);
loaderMeta.put("version", response.neoForgeVersion().version());
loaderMeta.put("rawVersion", response.neoForgeVersion().rawVersion());
packVersion.loader.metadata = loaderMeta;
packVersion.loader.className = "com.atlauncher.data.minecraft.loaders.neoforge.NeoForgeLoader";
} else if (forgeComponent != null) {
String forgeVersionString = forgeComponent.version;
if (ConfigManager.getConfigItem("useGraphql.loaderVersions", false) == true) {

View file

@ -1 +1 @@
3.4.31.3.Beta
3.4.32.0.Beta