diff options
Diffstat (limited to 'api')
-rw-r--r-- | api/logic/minecraft/ComponentUpdateTask.cpp | 9 | ||||
-rw-r--r-- | api/logic/minecraft/Mod.cpp | 55 | ||||
-rw-r--r-- | api/logic/minecraft/Mod.h | 1 |
3 files changed, 65 insertions, 0 deletions
diff --git a/api/logic/minecraft/ComponentUpdateTask.cpp b/api/logic/minecraft/ComponentUpdateTask.cpp index 37cc488d..15003160 100644 --- a/api/logic/minecraft/ComponentUpdateTask.cpp +++ b/api/logic/minecraft/ComponentUpdateTask.cpp @@ -586,6 +586,15 @@ void ComponentUpdateTask::resolveDependencies(bool checkOnly) { component->m_version = "3.1.2"; } + else if (add.uid == "net.fabricmc.intermediary") + { + auto minecraft = std::find_if(components.begin(), components.end(), [](ComponentPtr & cmp){ + return cmp->getID() == "net.minecraft"; + }); + if(minecraft != components.end()) { + component->m_version = (*minecraft)->getVersion(); + } + } } // HACK HACK HACK HACK FIXME: this is a placeholder for deciding what version to use. For now, it is hardcoded. // ############################################################################################################ diff --git a/api/logic/minecraft/Mod.cpp b/api/logic/minecraft/Mod.cpp index 069a27a4..6217c9d2 100644 --- a/api/logic/minecraft/Mod.cpp +++ b/api/logic/minecraft/Mod.cpp @@ -96,6 +96,19 @@ void Mod::repath(const QFileInfo &file) zip.close(); return; } + else if (zip.setCurrentFile("fabric.mod.json")) + { + if (!file.open(QIODevice::ReadOnly)) + { + zip.close(); + return; + } + + ReadFabricModInfo(file.readAll()); + file.close(); + zip.close(); + return; + } else if (zip.setCurrentFile("forgeversion.properties")) { if (!file.open(QIODevice::ReadOnly)) @@ -224,6 +237,48 @@ void Mod::ReadMCModInfo(QByteArray contents) } } +// https://fabricmc.net/wiki/documentation:fabric_mod_json +void Mod::ReadFabricModInfo(QByteArray contents) +{ + QJsonParseError jsonError; + QJsonDocument jsonDoc = QJsonDocument::fromJson(contents, &jsonError); + auto object = jsonDoc.object(); + auto schemaVersion = object.contains("schemaVersion") ? object.value("schemaVersion").toInt(0) : 0; + + m_mod_id = object.value("id").toString(); + m_version = object.value("version").toString(); + + m_name = object.contains("name") ? object.value("name").toString() : m_mod_id; + m_description = object.value("description").toString(); + + if (schemaVersion >= 1) + { + QJsonArray authors = object.value("authors").toArray(); + m_authors = ""; + + for (int i = 0; i < authors.size(); i++) + { + QString author_name = authors.at(i).isObject() + ? authors.at(i).toObject().value("name").toString() + : authors.at(i).toString(); + + if (i > 0) + m_authors += ", " + author_name; + else { + m_authors += author_name; + } + } + + if (object.contains("contact")) + { + QJsonObject contact = object.value("contact").toObject(); + + if (contact.contains("homepage")) + m_homeurl = contact.value("homepage").toString(); + } + } +} + void Mod::ReadForgeInfo(QByteArray contents) { // Read the data diff --git a/api/logic/minecraft/Mod.h b/api/logic/minecraft/Mod.h index 6c329363..63bf5ab4 100644 --- a/api/logic/minecraft/Mod.h +++ b/api/logic/minecraft/Mod.h @@ -113,6 +113,7 @@ public: private: void ReadMCModInfo(QByteArray contents); + void ReadFabricModInfo(QByteArray contents); void ReadForgeInfo(QByteArray contents); void ReadLiteModInfo(QByteArray contents); |