NOISSUE Add NeoForge support to mrpack importer and exporter

This commit is contained in:
arthomnix 2024-03-15 20:39:32 +00:00
parent d22707c7fc
commit 1b77965225
4 changed files with 18 additions and 5 deletions

View File

@ -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<Modrinth::File> 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);

View File

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

View File

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

View File

@ -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();