aboutsummaryrefslogtreecommitdiff
path: root/launcher/minecraft
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/minecraft')
-rw-r--r--launcher/minecraft/AssetsUtils.cpp4
-rw-r--r--launcher/minecraft/Component.h3
-rw-r--r--launcher/minecraft/ComponentUpdateTask.cpp4
-rw-r--r--launcher/minecraft/LaunchProfile.h2
-rw-r--r--launcher/minecraft/Library.cpp6
-rw-r--r--launcher/minecraft/MinecraftInstance.cpp103
-rw-r--r--launcher/minecraft/MinecraftInstance.h4
-rw-r--r--launcher/minecraft/MojangDownloadInfo.h12
-rw-r--r--launcher/minecraft/OneSixVersionFormat.cpp2
-rw-r--r--launcher/minecraft/PackProfile.cpp53
-rw-r--r--launcher/minecraft/PackProfile.h13
-rw-r--r--launcher/minecraft/ProfileUtils.cpp2
-rw-r--r--launcher/minecraft/Rule.h2
-rw-r--r--launcher/minecraft/World.cpp12
-rw-r--r--launcher/minecraft/WorldList.cpp11
-rw-r--r--launcher/minecraft/auth/AccountData.cpp4
-rw-r--r--launcher/minecraft/auth/AccountList.cpp7
-rw-r--r--launcher/minecraft/auth/MinecraftAccount.cpp6
-rw-r--r--launcher/minecraft/auth/Parsers.cpp8
-rw-r--r--launcher/minecraft/auth/steps/EntitlementsStep.cpp4
-rw-r--r--launcher/minecraft/gameoptions/GameOptions.cpp3
-rw-r--r--launcher/minecraft/launch/ExtractNatives.cpp12
-rw-r--r--launcher/minecraft/launch/LauncherPartLaunch.cpp2
-rw-r--r--launcher/minecraft/mod/DataPack.cpp2
-rw-r--r--launcher/minecraft/mod/DataPack.h2
-rw-r--r--launcher/minecraft/mod/Mod.cpp23
-rw-r--r--launcher/minecraft/mod/Mod.h4
-rw-r--r--launcher/minecraft/mod/ModDetails.h20
-rw-r--r--launcher/minecraft/mod/ModFolderModel.cpp71
-rw-r--r--launcher/minecraft/mod/ModFolderModel.h3
-rw-r--r--launcher/minecraft/mod/ResourceFolderModel.cpp10
-rw-r--r--launcher/minecraft/mod/ResourceFolderModel.h19
-rw-r--r--launcher/minecraft/mod/ResourcePack.cpp7
-rw-r--r--launcher/minecraft/mod/ResourcePack.h2
-rw-r--r--launcher/minecraft/mod/ResourcePackFolderModel.cpp4
-rw-r--r--launcher/minecraft/mod/TexturePack.cpp5
-rw-r--r--launcher/minecraft/mod/TexturePackFolderModel.cpp3
-rw-r--r--launcher/minecraft/mod/tasks/GetModDependenciesTask.cpp29
-rw-r--r--launcher/minecraft/mod/tasks/GetModDependenciesTask.h2
-rw-r--r--launcher/minecraft/mod/tasks/LocalDataPackParseTask.cpp2
-rw-r--r--launcher/minecraft/mod/tasks/LocalModParseTask.cpp33
-rw-r--r--launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp2
-rw-r--r--launcher/minecraft/services/CapeChange.cpp2
-rw-r--r--launcher/minecraft/update/AssetUpdateTask.cpp4
-rw-r--r--launcher/minecraft/update/FMLLibrariesTask.cpp4
45 files changed, 357 insertions, 175 deletions
diff --git a/launcher/minecraft/AssetsUtils.cpp b/launcher/minecraft/AssetsUtils.cpp
index 4923f0ef..4ef00707 100644
--- a/launcher/minecraft/AssetsUtils.cpp
+++ b/launcher/minecraft/AssetsUtils.cpp
@@ -46,8 +46,8 @@
#include "AssetsUtils.h"
#include "BuildConfig.h"
#include "FileSystem.h"
+#include "net/ApiDownload.h"
#include "net/ChecksumValidator.h"
-#include "net/Download.h"
#include "Application.h"
@@ -279,7 +279,7 @@ NetAction::Ptr AssetObject::getDownloadAction()
{
QFileInfo objectFile(getLocalPath());
if ((!objectFile.isFile()) || (objectFile.size() != size)) {
- auto objectDL = Net::Download::makeFile(getUrl(), objectFile.filePath());
+ auto objectDL = Net::ApiDownload::makeFile(getUrl(), objectFile.filePath());
if (hash.size()) {
auto rawHash = QByteArray::fromHex(hash.toLatin1());
objectDL->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawHash));
diff --git a/launcher/minecraft/Component.h b/launcher/minecraft/Component.h
index 00a912d6..3474a22e 100644
--- a/launcher/minecraft/Component.h
+++ b/launcher/minecraft/Component.h
@@ -25,7 +25,8 @@ class Component : public QObject, public ProblemProvider {
Component(PackProfile* parent, std::shared_ptr<Meta::Version> version);
Component(PackProfile* parent, const QString& uid, std::shared_ptr<VersionFile> file);
- virtual ~Component(){};
+ virtual ~Component() {}
+
void applyTo(LaunchProfile* profile);
bool isEnabled();
diff --git a/launcher/minecraft/ComponentUpdateTask.cpp b/launcher/minecraft/ComponentUpdateTask.cpp
index 0b85b81a..bb838043 100644
--- a/launcher/minecraft/ComponentUpdateTask.cpp
+++ b/launcher/minecraft/ComponentUpdateTask.cpp
@@ -2,14 +2,14 @@
#include "Component.h"
#include "ComponentUpdateTask_p.h"
-#include "OneSixVersionFormat.h"
#include "PackProfile.h"
#include "PackProfile_p.h"
#include "Version.h"
#include "cassert"
#include "meta/Index.h"
#include "meta/Version.h"
-#include "meta/VersionList.h"
+#include "minecraft/OneSixVersionFormat.h"
+#include "minecraft/ProfileUtils.h"
#include "net/Mode.h"
#include "Application.h"
diff --git a/launcher/minecraft/LaunchProfile.h b/launcher/minecraft/LaunchProfile.h
index 3acc1f19..12b31238 100644
--- a/launcher/minecraft/LaunchProfile.h
+++ b/launcher/minecraft/LaunchProfile.h
@@ -41,7 +41,7 @@
class LaunchProfile : public ProblemProvider {
public:
- virtual ~LaunchProfile(){};
+ virtual ~LaunchProfile() {}
public: /* application of profile variables from patches */
void applyMinecraftVersion(const QString& id);
diff --git a/launcher/minecraft/Library.cpp b/launcher/minecraft/Library.cpp
index a9c20845..0e8ddf03 100644
--- a/launcher/minecraft/Library.cpp
+++ b/launcher/minecraft/Library.cpp
@@ -38,8 +38,8 @@
#include <BuildConfig.h>
#include <FileSystem.h>
+#include <net/ApiDownload.h>
#include <net/ChecksumValidator.h>
-#include <net/Download.h>
void Library::getApplicableFiles(const RuntimeContext& runtimeContext,
QStringList& jar,
@@ -115,12 +115,12 @@ QList<NetAction::Ptr> Library::getDownloads(const RuntimeContext& runtimeContext
if (sha1.size()) {
auto rawSha1 = QByteArray::fromHex(sha1.toLatin1());
- auto dl = Net::Download::makeCached(url, entry, options);
+ auto dl = Net::ApiDownload::makeCached(url, entry, options);
dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawSha1));
qDebug() << "Checksummed Download for:" << rawName().serialize() << "storage:" << storage << "url:" << url;
out.append(dl);
} else {
- out.append(Net::Download::makeCached(url, entry, options));
+ out.append(Net::ApiDownload::makeCached(url, entry, options));
qDebug() << "Download for:" << rawName().serialize() << "storage:" << storage << "url:" << url;
}
return true;
diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp
index 305bff67..86ef3b30 100644
--- a/launcher/minecraft/MinecraftInstance.cpp
+++ b/launcher/minecraft/MinecraftInstance.cpp
@@ -3,8 +3,7 @@
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
* Copyright (C) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
- * Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
- * Copyright (c) 2023 seth <getchoo at tuta dot io>
+ * Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -88,6 +87,10 @@
#include "minecraft/gameoptions/GameOptions.h"
#include "minecraft/update/FoldersTask.h"
+#include "tools/BaseProfiler.h"
+
+#include <QActionGroup>
+
#ifdef Q_OS_LINUX
#include "MangoHud.h"
#endif
@@ -166,7 +169,9 @@ void MinecraftInstance::loadSpecificSettings()
// Native library workarounds
auto nativeLibraryWorkaroundsOverride = m_settings->registerSetting("OverrideNativeWorkarounds", false);
m_settings->registerOverride(global_settings->getSetting("UseNativeOpenAL"), nativeLibraryWorkaroundsOverride);
+ m_settings->registerOverride(global_settings->getSetting("CustomOpenALPath"), nativeLibraryWorkaroundsOverride);
m_settings->registerOverride(global_settings->getSetting("UseNativeGLFW"), nativeLibraryWorkaroundsOverride);
+ m_settings->registerOverride(global_settings->getSetting("CustomGLFWPath"), nativeLibraryWorkaroundsOverride);
// Peformance related options
auto performanceOverride = m_settings->registerSetting("OverridePerformance", false);
@@ -179,10 +184,6 @@ void MinecraftInstance::loadSpecificSettings()
m_settings->registerOverride(global_settings->getSetting("CloseAfterLaunch"), miscellaneousOverride);
m_settings->registerOverride(global_settings->getSetting("QuitAfterGameStop"), miscellaneousOverride);
- // Mod loader specific options
- auto modLoaderSettings = m_settings->registerSetting("OverrideModLoaderSettings", false);
- m_settings->registerOverride(global_settings->getSetting("DisableQuiltBeacon"), modLoaderSettings);
-
m_settings->set("InstanceType", "OneSix");
}
@@ -194,6 +195,12 @@ void MinecraftInstance::loadSpecificSettings()
m_settings->registerSetting("UseAccountForInstance", false);
m_settings->registerSetting("InstanceAccountId", "");
+ m_settings->registerSetting("ExportName", "");
+ m_settings->registerSetting("ExportVersion", "1.0.0");
+ m_settings->registerSetting("ExportSummary", "");
+ m_settings->registerSetting("ExportAuthor", "");
+ m_settings->registerSetting("ExportOptionalFiles", true);
+
qDebug() << "Instance-type specific settings were loaded!";
setSpecificSettingsLoaded(true);
@@ -229,6 +236,50 @@ QSet<QString> MinecraftInstance::traits() const
return profile->getTraits();
}
+// FIXME: move UI code out of MinecraftInstance
+void MinecraftInstance::populateLaunchMenu(QMenu* menu)
+{
+ QAction* normalLaunch = menu->addAction(tr("&Launch"));
+ normalLaunch->setShortcut(QKeySequence::Open);
+ QAction* normalLaunchOffline = menu->addAction(tr("Launch &Offline"));
+ normalLaunchOffline->setShortcut(QKeySequence(tr("Ctrl+Shift+O")));
+ QAction* normalLaunchDemo = menu->addAction(tr("Launch &Demo"));
+ normalLaunchDemo->setShortcut(QKeySequence(tr("Ctrl+Alt+O")));
+
+ normalLaunchDemo->setEnabled(supportsDemo());
+
+ connect(normalLaunch, &QAction::triggered, [this] { APPLICATION->launch(shared_from_this()); });
+ connect(normalLaunchOffline, &QAction::triggered, [this] { APPLICATION->launch(shared_from_this(), false, false); });
+ connect(normalLaunchDemo, &QAction::triggered, [this] { APPLICATION->launch(shared_from_this(), false, true); });
+
+ QString profilersTitle = tr("Profilers");
+ menu->addSeparator()->setText(profilersTitle);
+
+ auto profilers = new QActionGroup(menu);
+ profilers->setExclusive(true);
+ connect(profilers, &QActionGroup::triggered, [this](QAction* action) {
+ settings()->set("Profiler", action->data());
+ emit profilerChanged();
+ });
+
+ QAction* noProfilerAction = menu->addAction(tr("&No Profiler"));
+ noProfilerAction->setData("");
+ noProfilerAction->setCheckable(true);
+ noProfilerAction->setChecked(true);
+ profilers->addAction(noProfilerAction);
+
+ for (auto profiler = APPLICATION->profilers().begin(); profiler != APPLICATION->profilers().end(); profiler++) {
+ QAction* profilerAction = menu->addAction(profiler.value()->name());
+ profilers->addAction(profilerAction);
+ profilerAction->setData(profiler.key());
+ profilerAction->setCheckable(true);
+ profilerAction->setChecked(settings()->get("Profiler").toString() == profiler.key());
+
+ QString error;
+ profilerAction->setEnabled(profiler.value()->check(&error));
+ }
+}
+
QString MinecraftInstance::gameRoot() const
{
QFileInfo mcDir(FS::PathCombine(instanceRoot(), "minecraft"));
@@ -260,7 +311,7 @@ QString MinecraftInstance::getLocalLibraryPath() const
bool MinecraftInstance::supportsDemo() const
{
Version instance_ver{ getPackProfile()->getComponentVersion("net.minecraft") };
- // Demo mode was introduced in 1.3.1: https://minecraft.fandom.com/wiki/Demo_mode#History
+ // Demo mode was introduced in 1.3.1: https://minecraft.wiki/w/Demo_mode#History
// FIXME: Due to Version constraints atm, this can't handle well non-release versions
return instance_ver >= Version("1.3.1");
}
@@ -385,10 +436,31 @@ QStringList MinecraftInstance::extraArguments()
}
{
- const auto loaders = version->getModLoaders();
- if (loaders.has_value() && loaders.value() & ResourceAPI::Quilt && settings()->get("DisableQuiltBeacon").toBool())
- list.append("-Dloader.disable_beacon=true");
+ QString openALPath;
+ QString glfwPath;
+
+ if (settings()->get("UseNativeOpenAL").toBool()) {
+ openALPath = APPLICATION->m_detectedOpenALPath;
+ auto customPath = settings()->get("CustomOpenALPath").toString();
+ if (!customPath.isEmpty())
+ openALPath = customPath;
+ }
+ if (settings()->get("UseNativeGLFW").toBool()) {
+ glfwPath = APPLICATION->m_detectedGLFWPath;
+ auto customPath = settings()->get("CustomGLFWPath").toString();
+ if (!customPath.isEmpty())
+ glfwPath = customPath;
+ }
+
+ QFileInfo openALInfo(openALPath);
+ QFileInfo glfwInfo(glfwPath);
+
+ if (!openALPath.isEmpty() && openALInfo.exists())
+ list.append("-Dorg.lwjgl.openal.libname=" + openALInfo.absoluteFilePath());
+ if (!glfwPath.isEmpty() && glfwInfo.exists())
+ list.append("-Dorg.lwjgl.glfw.libname=" + glfwInfo.absoluteFilePath());
}
+
return list;
}
@@ -868,13 +940,16 @@ QString MinecraftInstance::getStatusbarDescription()
if (m_settings->get("ShowGameTime").toBool()) {
if (lastTimePlayed() > 0) {
QDateTime lastLaunchTime = QDateTime::fromMSecsSinceEpoch(lastLaunch());
- description.append(tr(", last played on %1 for %2")
- .arg(QLocale().toString(lastLaunchTime, QLocale::ShortFormat))
- .arg(Time::prettifyDuration(lastTimePlayed())));
+ description.append(
+ tr(", last played on %1 for %2")
+ .arg(QLocale().toString(lastLaunchTime, QLocale::ShortFormat))
+ .arg(Time::prettifyDuration(lastTimePlayed(), APPLICATION->settings()->get("ShowGameTimeWithoutDays").toBool())));
}
if (totalTimePlayed() > 0) {
- description.append(tr(", total played for %1").arg(Time::prettifyDuration(totalTimePlayed())));
+ description.append(
+ tr(", total played for %1")
+ .arg(Time::prettifyDuration(totalTimePlayed(), APPLICATION->settings()->get("ShowGameTimeWithoutDays").toBool())));
}
}
if (hasCrashed()) {
diff --git a/launcher/minecraft/MinecraftInstance.h b/launcher/minecraft/MinecraftInstance.h
index c331cc6f..dabd44ba 100644
--- a/launcher/minecraft/MinecraftInstance.h
+++ b/launcher/minecraft/MinecraftInstance.h
@@ -2,7 +2,7 @@
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
- * Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
+ * Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -70,6 +70,8 @@ class MinecraftInstance : public BaseInstance {
bool canExport() const override { return true; }
+ void populateLaunchMenu(QMenu* menu) override;
+
////// Directories and files //////
QString jarModsDir() const;
QString resourcePacksDir() const;
diff --git a/launcher/minecraft/MojangDownloadInfo.h b/launcher/minecraft/MojangDownloadInfo.h
index b98a0168..855dbe00 100644
--- a/launcher/minecraft/MojangDownloadInfo.h
+++ b/launcher/minecraft/MojangDownloadInfo.h
@@ -19,8 +19,8 @@ struct MojangDownloadInfo {
};
struct MojangLibraryDownloadInfo {
- MojangLibraryDownloadInfo(MojangDownloadInfo::Ptr artifact) : artifact(artifact){};
- MojangLibraryDownloadInfo(){};
+ MojangLibraryDownloadInfo(MojangDownloadInfo::Ptr artifact_) : artifact(artifact_) {}
+ MojangLibraryDownloadInfo() {}
// types
typedef std::shared_ptr<MojangLibraryDownloadInfo> Ptr;
@@ -47,18 +47,18 @@ struct MojangAssetIndexInfo : public MojangDownloadInfo {
// methods
MojangAssetIndexInfo() {}
- MojangAssetIndexInfo(QString id)
+ MojangAssetIndexInfo(QString id_)
{
- this->id = id;
+ this->id = id_;
// HACK: ignore assets from other version files than Minecraft
// workaround for stupid assets issue caused by amazon:
// https://www.theregister.co.uk/2017/02/28/aws_is_awol_as_s3_goes_haywire/
- if (id == "legacy") {
+ if (id_ == "legacy") {
url = "https://piston-meta.mojang.com/mc/assets/legacy/c0fd82e8ce9fbc93119e40d96d5a4e62cfa3f729/legacy.json";
}
// HACK
else {
- url = "https://s3.amazonaws.com/Minecraft.Download/indexes/" + id + ".json";
+ url = "https://s3.amazonaws.com/Minecraft.Download/indexes/" + id_ + ".json";
}
known = false;
}
diff --git a/launcher/minecraft/OneSixVersionFormat.cpp b/launcher/minecraft/OneSixVersionFormat.cpp
index e2455325..306c95a6 100644
--- a/launcher/minecraft/OneSixVersionFormat.cpp
+++ b/launcher/minecraft/OneSixVersionFormat.cpp
@@ -350,7 +350,7 @@ QJsonDocument OneSixVersionFormat::versionFileToJson(const VersionFilePtr& patch
}
}
-LibraryPtr OneSixVersionFormat::plusJarModFromJson(ProblemContainer& problems,
+LibraryPtr OneSixVersionFormat::plusJarModFromJson([[maybe_unused]] ProblemContainer& problems,
const QJsonObject& libObj,
const QString& filename,
const QString& originalName)
diff --git a/launcher/minecraft/PackProfile.cpp b/launcher/minecraft/PackProfile.cpp
index 82fc779e..9e42c5dd 100644
--- a/launcher/minecraft/PackProfile.cpp
+++ b/launcher/minecraft/PackProfile.cpp
@@ -58,14 +58,14 @@
#include "ComponentUpdateTask.h"
#include "PackProfile.h"
#include "PackProfile_p.h"
+#include "minecraft/mod/Mod.h"
+#include "modplatform/ModIndex.h"
-#include "Application.h"
-#include "modplatform/ResourceAPI.h"
-
-static const QMap<QString, ResourceAPI::ModLoaderType> modloaderMapping{ { "net.minecraftforge", ResourceAPI::Forge },
- { "net.fabricmc.fabric-loader", ResourceAPI::Fabric },
- { "org.quiltmc.quilt-loader", ResourceAPI::Quilt },
- { "com.mumfrey.liteloader", ResourceAPI::LiteLoader } };
+static const QMap<QString, ModPlatform::ModLoaderType> modloaderMapping{ { "net.neoforged", ModPlatform::NeoForge },
+ { "net.minecraftforge", ModPlatform::Forge },
+ { "net.fabricmc.fabric-loader", ModPlatform::Fabric },
+ { "org.quiltmc.quilt-loader", ModPlatform::Quilt },
+ { "com.mumfrey.liteloader", ModPlatform::LiteLoader } };
PackProfile::PackProfile(MinecraftInstance* instance) : QAbstractListModel()
{
@@ -204,10 +204,10 @@ static bool loadPackProfile(PackProfile* parent,
}
auto orderArray = Json::requireArray(obj.value("components"));
for (auto item : orderArray) {
- auto obj = Json::requireObject(item, "Component must be an object.");
- container.append(componentFromJsonV1(parent, componentJsonPattern, obj));
+ auto comp_obj = Json::requireObject(item, "Component must be an object.");
+ container.append(componentFromJsonV1(parent, componentJsonPattern, comp_obj));
}
- } catch (const JSONValidationError& err) {
+ } catch ([[maybe_unused]] const JSONValidationError& err) {
qCritical() << "Couldn't parse" << componentsFile.fileName() << ": bad file format";
container.clear();
return false;
@@ -377,7 +377,7 @@ void PackProfile::insertComponent(size_t index, ComponentPtr component)
qWarning() << "Attempt to add a component that is already present!";
return;
}
- beginInsertRows(QModelIndex(), index, index);
+ beginInsertRows(QModelIndex(), static_cast<int>(index), static_cast<int>(index));
d->components.insert(index, component);
d->componentIndex[id] = component;
endInsertRows();
@@ -389,7 +389,7 @@ void PackProfile::componentDataChanged()
{
auto objPtr = qobject_cast<Component*>(sender());
if (!objPtr) {
- qWarning() << "PackProfile got dataChenged signal from a non-Component!";
+ qWarning() << "PackProfile got dataChanged signal from a non-Component!";
return;
}
if (objPtr->getID() == "net.minecraft") {
@@ -405,7 +405,7 @@ void PackProfile::componentDataChanged()
}
index++;
}
- qWarning() << "PackProfile got dataChenged signal from a Component which does not belong to it!";
+ qWarning() << "PackProfile got dataChanged signal from a Component which does not belong to it!";
}
bool PackProfile::remove(const int index)
@@ -483,9 +483,9 @@ ComponentPtr PackProfile::getComponent(const QString& id)
return (*iter);
}
-ComponentPtr PackProfile::getComponent(int index)
+ComponentPtr PackProfile::getComponent(size_t index)
{
- if (index < 0 || index >= d->components.size()) {
+ if (index >= static_cast<size_t>(d->components.size())) {
return nullptr;
}
return d->components[index];
@@ -547,7 +547,7 @@ QVariant PackProfile::data(const QModelIndex& index, int role) const
return QVariant();
}
-bool PackProfile::setData(const QModelIndex& index, const QVariant& value, int role)
+bool PackProfile::setData(const QModelIndex& index, [[maybe_unused]] const QVariant& value, int role)
{
if (!index.isValid() || index.row() < 0 || index.row() >= rowCount(index.parent())) {
return false;
@@ -989,12 +989,12 @@ void PackProfile::disableInteraction(bool disable)
}
}
-std::optional<ResourceAPI::ModLoaderTypes> PackProfile::getModLoaders()
+std::optional<ModPlatform::ModLoaderTypes> PackProfile::getModLoaders()
{
- ResourceAPI::ModLoaderTypes result;
+ ModPlatform::ModLoaderTypes result;
bool has_any_loader = false;
- QMapIterator<QString, ResourceAPI::ModLoaderType> i(modloaderMapping);
+ QMapIterator<QString, ModPlatform::ModLoaderType> i(modloaderMapping);
while (i.hasNext()) {
i.next();
@@ -1008,3 +1008,18 @@ std::optional<ResourceAPI::ModLoaderTypes> PackProfile::getModLoaders()
return {};
return result;
}
+
+std::optional<ModPlatform::ModLoaderTypes> PackProfile::getSupportedModLoaders()
+{
+ auto loadersOpt = getModLoaders();
+ if (!loadersOpt.has_value())
+ return loadersOpt;
+ auto loaders = loadersOpt.value();
+ // TODO: remove this or add version condition once Quilt drops official Fabric support
+ if (loaders & ModPlatform::Quilt)
+ loaders |= ModPlatform::Fabric;
+ // TODO: remove this or add version condition once NeoForge drops official Forge support
+ if (loaders & ModPlatform::NeoForge)
+ loaders |= ModPlatform::Forge;
+ return loaders;
+}
diff --git a/launcher/minecraft/PackProfile.h b/launcher/minecraft/PackProfile.h
index a5e5cb1a..e72b6ebf 100644
--- a/launcher/minecraft/PackProfile.h
+++ b/launcher/minecraft/PackProfile.h
@@ -44,14 +44,11 @@
#include <QList>
#include <QString>
#include <memory>
+#include <optional>
-#include "BaseVersion.h"
#include "Component.h"
#include "LaunchProfile.h"
-#include "Library.h"
-#include "MojangDownloadInfo.h"
-#include "ProfileUtils.h"
-#include "modplatform/ResourceAPI.h"
+#include "modplatform/ModIndex.h"
#include "net/Mode.h"
class MinecraftInstance;
@@ -140,13 +137,15 @@ class PackProfile : public QAbstractListModel {
ComponentPtr getComponent(const QString& id);
/// get the profile component by index
- ComponentPtr getComponent(int index);
+ ComponentPtr getComponent(size_t index);
/// Add the component to the internal list of patches
// todo(merged): is this the best approach
void appendComponent(ComponentPtr component);
- std::optional<ResourceAPI::ModLoaderTypes> getModLoaders();
+ std::optional<ModPlatform::ModLoaderTypes> getModLoaders();
+ // this returns aditional loaders(Quilt supports fabric and NeoForge supports Forge)
+ std::optional<ModPlatform::ModLoaderTypes> getSupportedModLoaders();
private:
void scheduleSave();
diff --git a/launcher/minecraft/ProfileUtils.cpp b/launcher/minecraft/ProfileUtils.cpp
index 18a4b7d0..d56ed14b 100644
--- a/launcher/minecraft/ProfileUtils.cpp
+++ b/launcher/minecraft/ProfileUtils.cpp
@@ -82,7 +82,7 @@ bool readOverrideOrders(QString path, PatchOrder& order)
for (auto item : orderArray) {
order.append(Json::requireString(item));
}
- } catch (const JSONValidationError& err) {
+ } catch ([[maybe_unused]] const JSONValidationError& err) {
qCritical() << "Couldn't parse" << orderFile.fileName() << ": bad file format";
qWarning() << "Ignoring overriden order";
order.clear();
diff --git a/launcher/minecraft/Rule.h b/launcher/minecraft/Rule.h
index 483cd936..c6cdbc43 100644
--- a/launcher/minecraft/Rule.h
+++ b/launcher/minecraft/Rule.h
@@ -55,7 +55,7 @@ class Rule {
public:
Rule(RuleAction result) : m_result(result) {}
- virtual ~Rule(){};
+ virtual ~Rule() {}
virtual QJsonObject toJson() = 0;
RuleAction apply(const Library* parent, const RuntimeContext& runtimeContext)
{
diff --git a/launcher/minecraft/World.cpp b/launcher/minecraft/World.cpp
index 62e0279a..1a680ac5 100644
--- a/launcher/minecraft/World.cpp
+++ b/launcher/minecraft/World.cpp
@@ -368,11 +368,11 @@ optional<QString> read_string(nbt::value& parent, const char* name)
}
auto& tag_str = namedValue.as<nbt::tag_string>();
return QString::fromStdString(tag_str.get());
- } catch (const std::out_of_range& e) {
+ } catch ([[maybe_unused]] const std::out_of_range& e) {
// fallback for old world formats
qWarning() << "String NBT tag" << name << "could not be found.";
return nullopt;
- } catch (const std::bad_cast& e) {
+ } catch ([[maybe_unused