From 1b7796522574dd71c2157d9cc40cf33eab55bb33 Mon Sep 17 00:00:00 2001 From: arthomnix Date: Fri, 15 Mar 2024 20:39:32 +0000 Subject: [PATCH] NOISSUE Add NeoForge support to mrpack importer and exporter --- launcher/InstanceImportTask.cpp | 12 ++++++++++-- .../modrinth/ModrinthInstanceExportTask.cpp | 5 ++++- .../modrinth/ModrinthInstanceExportTask.h | 3 ++- launcher/ui/dialogs/ModrinthExportDialog.cpp | 3 ++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/launcher/InstanceImportTask.cpp b/launcher/InstanceImportTask.cpp index a90166fa..ca87b763 100644 --- a/launcher/InstanceImportTask.cpp +++ b/launcher/InstanceImportTask.cpp @@ -1,4 +1,4 @@ -/* Copyright 2013-2021 MultiMC Contributors +/* Copyright 2013-2024 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -293,7 +293,7 @@ bool mergeOverrides(const QString &fromDir, const QString &toDir) { void InstanceImportTask::processModrinth() { std::vector files; - QString minecraftVersion, fabricVersion, quiltVersion, forgeVersion; + QString minecraftVersion, fabricVersion, quiltVersion, forgeVersion, neoforgeVersion; try { QString indexPath = FS::PathCombine(m_stagingPath, "modrinth.index.json"); @@ -392,6 +392,12 @@ void InstanceImportTask::processModrinth() { throw JSONValidationError("Duplicate Forge version"); forgeVersion = Json::requireValueString(*it, "Forge version"); } + else if (name == "neoforge") + { + if (!neoforgeVersion.isEmpty()) + throw JSONValidationError("Duplicate NeoForge version"); + neoforgeVersion = Json::requireValueString(*it, "NeoForge version"); + } else { throw JSONValidationError("Unknown dependency type: " + name); @@ -446,6 +452,8 @@ void InstanceImportTask::processModrinth() { components->setComponentVersion("org.quiltmc.quilt-loader", quiltVersion, true); if (!forgeVersion.isEmpty()) components->setComponentVersion("net.minecraftforge", forgeVersion, true); + if (!neoforgeVersion.isEmpty()) + components->setComponentVersion("net.neoforged", neoforgeVersion, true); if (m_instIcon != "default") { instance.setIconKey(m_instIcon); diff --git a/launcher/modplatform/modrinth/ModrinthInstanceExportTask.cpp b/launcher/modplatform/modrinth/ModrinthInstanceExportTask.cpp index 6f09c09c..be57fbb7 100644 --- a/launcher/modplatform/modrinth/ModrinthInstanceExportTask.cpp +++ b/launcher/modplatform/modrinth/ModrinthInstanceExportTask.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2023 arthomnix + * Copyright 2023-2024 arthomnix * * This source is subject to the Microsoft Public License (MS-PL). * Please see the COPYING.md file for more information. @@ -213,6 +213,9 @@ void InstanceExportTask::lookupSucceeded() if (!m_settings.quiltVersion.isEmpty()) { dependencies.insert("quilt-loader", m_settings.quiltVersion); } + if (!m_settings.neoforgeVersion.isEmpty()) { + dependencies.insert("neoforge", m_settings.neoforgeVersion); + } indexJson.insert("dependencies", dependencies); diff --git a/launcher/modplatform/modrinth/ModrinthInstanceExportTask.h b/launcher/modplatform/modrinth/ModrinthInstanceExportTask.h index a1be67f3..93d4625c 100644 --- a/launcher/modplatform/modrinth/ModrinthInstanceExportTask.h +++ b/launcher/modplatform/modrinth/ModrinthInstanceExportTask.h @@ -1,5 +1,5 @@ /* - * Copyright 2023 arthomnix + * Copyright 2023-2024 arthomnix * * This source is subject to the Microsoft Public License (MS-PL). * Please see the COPYING.md file for more information. @@ -33,6 +33,7 @@ struct ExportSettings QString forgeVersion; QString fabricVersion; QString quiltVersion; + QString neoforgeVersion; QString exportPath; }; diff --git a/launcher/ui/dialogs/ModrinthExportDialog.cpp b/launcher/ui/dialogs/ModrinthExportDialog.cpp index 14c919c9..24a66af7 100644 --- a/launcher/ui/dialogs/ModrinthExportDialog.cpp +++ b/launcher/ui/dialogs/ModrinthExportDialog.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2023 arthomnix + * Copyright 2023-2024 arthomnix * * This source is subject to the Microsoft Public License (MS-PL). * Please see the COPYING.md file for more information. @@ -107,6 +107,7 @@ void ModrinthExportDialog::accept() settings.forgeVersion = minecraftInstance->getPackProfile()->getComponentVersion("net.minecraftforge"); settings.fabricVersion = minecraftInstance->getPackProfile()->getComponentVersion("net.fabricmc.fabric-loader"); settings.quiltVersion = minecraftInstance->getPackProfile()->getComponentVersion("org.quiltmc.quilt-loader"); + settings.neoforgeVersion = minecraftInstance->getPackProfile()->getComponentVersion("net.neoforged"); settings.exportPath = ui->file->text();