Merge pull request #431 from Scrumplex/feat-quilt-modrinth

Query for Fabric mods if Quilt is in use
This commit is contained in:
Ezekiel Smith 2022-04-17 13:46:22 +10:00 committed by GitHub
commit 703bf9bb7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View File

@ -23,7 +23,7 @@ class FlameAPI : public NetworkModAPI {
.arg(args.offset) .arg(args.offset)
.arg(args.search) .arg(args.search)
.arg(args.sorting) .arg(args.sorting)
.arg(args.mod_loader) .arg(getMappedModLoader(args.mod_loader))
.arg(gameVersionStr); .arg(gameVersionStr);
}; };
@ -31,4 +31,13 @@ class FlameAPI : public NetworkModAPI {
{ {
return QString("https://addons-ecs.forgesvc.net/api/v2/addon/%1/files").arg(args.addonId); return QString("https://addons-ecs.forgesvc.net/api/v2/addon/%1/files").arg(args.addonId);
}; };
public:
static auto getMappedModLoader(const ModLoaderType type) -> const ModLoaderType
{
// TODO: remove this once Quilt drops official Fabric support
if (type == Quilt) // NOTE: Most if not all Fabric mods should work *currently*
return Fabric;
return type;
}
}; };

View File

@ -3,6 +3,7 @@
#include "Json.h" #include "Json.h"
#include "minecraft/MinecraftInstance.h" #include "minecraft/MinecraftInstance.h"
#include "minecraft/PackProfile.h" #include "minecraft/PackProfile.h"
#include "modplatform/flame/FlameAPI.h"
#include "net/NetJob.h" #include "net/NetJob.h"
void FlameMod::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj) void FlameMod::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
@ -43,8 +44,9 @@ void FlameMod::loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
BaseInstance* inst) BaseInstance* inst)
{ {
QVector<ModPlatform::IndexedVersion> unsortedVersions; QVector<ModPlatform::IndexedVersion> unsortedVersions;
bool hasFabric = !(dynamic_cast<MinecraftInstance*>(inst))->getPackProfile()->getComponentVersion("net.fabricmc.fabric-loader").isEmpty(); auto profile = (dynamic_cast<MinecraftInstance*>(inst))->getPackProfile();
QString mcVersion = (dynamic_cast<MinecraftInstance*>(inst))->getPackProfile()->getComponentVersion("net.minecraft"); bool hasFabric = FlameAPI::getMappedModLoader(profile->getModLoader()) == ModAPI::Fabric;
QString mcVersion = profile->getComponentVersion("net.minecraft");
for (auto versionIter : arr) { for (auto versionIter : arr) {
auto obj = versionIter.toObject(); auto obj = versionIter.toObject();

View File

@ -54,6 +54,9 @@ class ModrinthAPI : public NetworkModAPI {
{ {
if (type == Unspecified) if (type == Unspecified)
return "fabric, forge, quilt"; return "fabric, forge, quilt";
// TODO: remove this once Quilt drops official Fabric support
if (type == Quilt) // NOTE: Most if not all Fabric mods should work *currently*
return "fabric, quilt";
return ModAPI::getModLoaderString(type); return ModAPI::getModLoaderString(type);
} }