diff options
-rw-r--r-- | api/logic/InstanceImportTask.cpp | 64 | ||||
-rw-r--r-- | api/logic/minecraft/curse/PackManifest.cpp | 9 |
2 files changed, 66 insertions, 7 deletions
diff --git a/api/logic/InstanceImportTask.cpp b/api/logic/InstanceImportTask.cpp index 100ec525..2005b61f 100644 --- a/api/logic/InstanceImportTask.cpp +++ b/api/logic/InstanceImportTask.cpp @@ -175,6 +175,12 @@ void InstanceImportTask::extractAborted() void InstanceImportTask::processCurse(const QFileInfo & manifest) { + const static QMap<QString,QString> forgemap = { + {"1.2.5", "3.4.9.171"}, + {"1.4.2", "6.0.1.355"}, + {"1.4.7", "6.6.2.534"}, + {"1.5.2", "7.8.1.737"} + }; Curse::Manifest pack; try { @@ -187,7 +193,6 @@ void InstanceImportTask::processCurse(const QFileInfo & manifest) return; } m_packRoot = manifest.absolutePath(); - QString configPath = FS::PathCombine(m_packRoot, "instance.cfg"); if(!pack.overrides.isEmpty()) { QString overridePath = FS::PathCombine(m_packRoot, pack.overrides); @@ -213,17 +218,70 @@ void InstanceImportTask::processCurse(const QFileInfo & manifest) qWarning() << "Unknown mod loader in curse manifest:" << id; } + QString configPath = FS::PathCombine(m_packRoot, "instance.cfg"); auto instanceSettings = std::make_shared<INISettingsObject>(configPath); instanceSettings->registerSetting("InstanceType", "Legacy"); instanceSettings->set("InstanceType", "OneSix"); OneSixInstance instance(m_globalSettings, instanceSettings, m_packRoot); - instance.setIntendedVersionId(pack.minecraft.version); + auto mcVersion = pack.minecraft.version; + // Hack to correct some 'special curse sauce'... + if(mcVersion.endsWith('.')) + { + mcVersion.remove(QRegExp("[.]+$")); + qWarning() << "Mysterious trailing dots removed from Minecraft version while importing Curse pack."; + } + instance.setComponentVersion("net.minecraft", mcVersion); if(!forgeVersion.isEmpty()) { + // FIXME: dirty, nasty, hack. Proper solution requires dependency resolution and knowledge of the metadata. + if(forgeVersion == "recommended") + { + if(forgemap.contains(mcVersion)) + { + forgeVersion = forgemap[mcVersion]; + } + else + { + qWarning() << "Could not map recommended forge version for" << mcVersion; + } + } instance.setComponentVersion("net.minecraftforge", forgeVersion); } + if (m_instIcon != "default") + { + instance.setIconKey(m_instIcon); + } + else + { + if(pack.name.contains("Direwolf20")) + { + instance.setIconKey("steve"); + } + else if(pack.name.contains("FTB") || pack.name.contains("Feed The Beast")) + { + instance.setIconKey("ftb_logo"); + } + } + instance.init(); + QString jarmodsPath = FS::PathCombine(m_packRoot, "minecraft", "jarmods"); + QFileInfo jarmodsInfo(jarmodsPath); + if(jarmodsInfo.isDir()) + { + // install all the jar mods + qDebug() << "Found jarmods:"; + QDir jarmodsDir(jarmodsPath); + QStringList jarMods; + for (auto info: jarmodsDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files)) + { + qDebug() << info.fileName(); + jarMods.push_back(info.absoluteFilePath()); + } + auto profile = instance.getMinecraftProfile(); + profile->installJarMods(jarMods); + // nuke the original files + FS::deletePath(jarmodsPath); + } instance.setName(m_instName); - instance.setIconKey(m_instIcon); m_curseResolver.reset(new Curse::FileResolvingTask(pack)); connect(m_curseResolver.get(), &Curse::FileResolvingTask::succeeded, [&]() { diff --git a/api/logic/minecraft/curse/PackManifest.cpp b/api/logic/minecraft/curse/PackManifest.cpp index 2fde8a01..7d9c2f89 100644 --- a/api/logic/minecraft/curse/PackManifest.cpp +++ b/api/logic/minecraft/curse/PackManifest.cpp @@ -18,7 +18,8 @@ static void loadModloaderV1(Curse::Modloader & m, QJsonObject & modLoader) static void loadMinecraftV1(Curse::Minecraft & m, QJsonObject & minecraft) { m.version = Json::requireString(minecraft, "version"); - // FIXME: default unknown, assuming empty. Meaning also unknown. + // extra libraries... apparently only used for a custom Minecraft launcher in the 1.2.5 FTB retro pack + // intended use is likely hardcoded in the Curse client, the manifest says nothing m.libraries = Json::ensureString(minecraft, QString("libraries"), QString()); auto arr = Json::ensureArray(minecraft, "modLoaders", QJsonArray()); for (const auto & item : arr) @@ -34,9 +35,9 @@ static void loadManifestV1(Curse::Manifest & m, QJsonObject & manifest) { auto mc = Json::requireObject(manifest, "minecraft"); loadMinecraftV1(m.minecraft, mc); - m.name = Json::requireString(manifest, "name"); - m.version = Json::requireString(manifest, "version"); - m.author = Json::requireString(manifest, "author"); + m.name = Json::ensureString(manifest, QString("name"), "Unnamed"); + m.version = Json::ensureString(manifest, QString("version"), QString()); + m.author = Json::ensureString(manifest, QString("author"), "Anonymous Coward"); auto arr = Json::ensureArray(manifest, "files", QJsonArray()); for (const auto & item : arr) { |