From 384680ca135eb8fbe5fe366af7c2328e36e7b12c Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Thu, 25 Feb 2021 13:55:26 +0000 Subject: [PATCH 1/3] NOISSUE Support Fabric mod loader for modpacks.ch There aren't any (currently) packs on modpacks.ch that use Fabric, but they do have support in their modpacklauncher. This patch just means we preemptively have support should any packs that require it be introduced. --- .../modplatform/modpacksch/FTBPackInstallTask.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp b/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp index dc2b05fe..73b8975a 100644 --- a/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp +++ b/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp @@ -30,7 +30,7 @@ void PackInstallTask::executeTask() if (vInfo.name == m_version_name) { found = true; version = vInfo; - continue; + break; } } @@ -102,14 +102,19 @@ void PackInstallTask::install() for(auto target : m_version.targets) { if(target.type == "game" && target.name == "minecraft") { components->setComponentVersion("net.minecraft", target.version, true); - continue; + break; } } for(auto target : m_version.targets) { - if(target.type == "modloader" && target.name == "forge") { + if(target.type != "modloader") continue; + + if(target.name == "forge") { components->setComponentVersion("net.minecraftforge", target.version, true); } + else if(target.name == "fabric") { + components->setComponentVersion("net.fabricmc.fabric-loader", target.version, true); + } } components->saveNow(); From 9d91cd496f6c43ae0098632fe1ba8bf29ac0ba4b Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Thu, 25 Feb 2021 14:34:51 +0000 Subject: [PATCH 2/3] NOISSUE Download all mods before writing the instance for modpacks.ch This is prepatory work for implementing jarmods support for modpacks.ch, where we will need to look through files in a directory - which would require that those files are present at such time. This might even fix some weird bugs, maybe - I've not encountered any bugs from how this previously worked, but I feel that what's going on is slightly clearer now. --- .../modpacksch/FTBPackInstallTask.cpp | 78 ++++++++++--------- .../modpacksch/FTBPackInstallTask.h | 1 + 2 files changed, 44 insertions(+), 35 deletions(-) diff --git a/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp b/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp index 73b8975a..bbf60912 100644 --- a/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp +++ b/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp @@ -76,7 +76,7 @@ void PackInstallTask::onDownloadSucceeded() } m_version = version; - install(); + downloadPack(); } void PackInstallTask::onDownloadFailed(QString reason) @@ -85,6 +85,45 @@ void PackInstallTask::onDownloadFailed(QString reason) emitFailed(reason); } +void PackInstallTask::downloadPack() +{ + setStatus(tr("Downloading mods...")); + + jobPtr.reset(new NetJob(tr("Mod download"))); + for(auto file : m_version.files) { + if(file.serverOnly) continue; + + auto relpath = FS::PathCombine("minecraft", file.path, file.name); + auto path = FS::PathCombine(m_stagingPath, relpath); + + qDebug() << "Will download" << file.url << "to" << path; + auto dl = Net::Download::makeFile(file.url, path); + jobPtr->addNetAction(dl); + } + + connect(jobPtr.get(), &NetJob::succeeded, this, [&]() + { + jobPtr.reset(); + install(); + }); + connect(jobPtr.get(), &NetJob::failed, [&](QString reason) + { + jobPtr.reset(); + + // FIXME: Temporarily ignore file download failures (matching FTB's installer), + // while FTB's data is fucked. + qWarning() << "Failed to download files for modpack: " + reason; + + install(); + }); + connect(jobPtr.get(), &NetJob::progress, [&](qint64 current, qint64 total) + { + setProgress(current, total); + }); + + jobPtr->start(); +} + void PackInstallTask::install() { setStatus(tr("Installing modpack")); @@ -116,45 +155,14 @@ void PackInstallTask::install() components->setComponentVersion("net.fabricmc.fabric-loader", target.version, true); } } + components->saveNow(); - jobPtr.reset(new NetJob(tr("Mod download"))); - for(auto file : m_version.files) { - if(file.serverOnly) continue; - - auto relpath = FS::PathCombine("minecraft", file.path, file.name); - auto path = FS::PathCombine(m_stagingPath, relpath); - - qDebug() << "Will download" << file.url << "to" << path; - auto dl = Net::Download::makeFile(file.url, path); - jobPtr->addNetAction(dl); - } - - connect(jobPtr.get(), &NetJob::succeeded, this, [&]() - { - jobPtr.reset(); - emitSucceeded(); - }); - connect(jobPtr.get(), &NetJob::failed, [&](QString reason) - { - jobPtr.reset(); - - // FIXME: Temporarily ignore file download failures (matching FTB's installer), - // while FTB's data is fucked. - qWarning() << "Failed to download files for modpack: " + reason; - emitSucceeded(); - }); - connect(jobPtr.get(), &NetJob::progress, [&](qint64 current, qint64 total) - { - setProgress(current, total); - }); - - setStatus(tr("Downloading mods...")); - jobPtr->start(); - instance.setName(m_instName); instance.setIconKey(m_instIcon); instanceSettings->resumeSave(); + + emitSucceeded(); } } diff --git a/api/logic/modplatform/modpacksch/FTBPackInstallTask.h b/api/logic/modplatform/modpacksch/FTBPackInstallTask.h index c5a80751..4f7786fd 100644 --- a/api/logic/modplatform/modpacksch/FTBPackInstallTask.h +++ b/api/logic/modplatform/modpacksch/FTBPackInstallTask.h @@ -26,6 +26,7 @@ private slots: void onDownloadFailed(QString reason); private: + void downloadPack(); void install(); private: From 9c69b0cddee5445e315a063761c1a4ae7dfbfacf Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Thu, 25 Feb 2021 14:43:04 +0000 Subject: [PATCH 3/3] NOISSUE Install jarmods for modpacks.ch This patch will now install any jarmods from modpacks.ch packs, searching the 'jarmods' directory to find them. --- .../modplatform/modpacksch/FTBPackInstallTask.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp b/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp index bbf60912..59546b00 100644 --- a/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp +++ b/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp @@ -156,6 +156,18 @@ void PackInstallTask::install() } } + // install any jar mods + QDir jarModsDir(FS::PathCombine(m_stagingPath, "minecraft", "jarmods")); + if (jarModsDir.exists()) { + QStringList jarMods; + + for (const auto& info : jarModsDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files)) { + jarMods.push_back(info.absoluteFilePath()); + } + + components->installJarMods(jarMods); + } + components->saveNow(); instance.setName(m_instName);