Getting PolyMC to download "blocked" Minecraft mod packs
I had the urge to play modded Minecraft again and happened across some information that Curseforge has been trying to block 3rd party launchers from downloading "disabled" mods (creators can explicitly disallow downloads not from the website or the 1st party launcher).
Being one who does not enjoy having software forced upon, I went searching for a workaround but could only find one that was already removed. Thus, I hacked together a patch for PolyMC myself.
Here are the steps to do it yourself; you need to be able to build PolyMC yourself and operate a git repo both of which are described on PolyMC's build instructions.
- Set up PolyMC's build environment
- Edit
/launcher/modplatform/flame/FileResolvingTask.cpp
:@@ -42,6 +42,12 @@ void Flame::FileResolvingTask::netJobFinished() out.parseFromObject(Json::requireObject(file)); } catch (const JSONValidationError& e) { qDebug() << "Blocked mod on curseforge" << out.fileName; + + out.url = QUrl(QString("https://media.forgecdn.net/files/%1/%2/%3") + .arg(QString::number(QString::number(out.fileId).leftRef(4).toInt()) + ,QString::number(QString::number(out.fileId).rightRef(3).toInt()) + ,QUrl::toPercentEncoding(out.fileName)), QUrl::TolerantMode); + auto hash = out.hash; if(!hash.isEmpty()) { auto url = QString("https://api.modrinth.com/v2/version_file/%1?algorithm=sha1").arg(hash);
- Edit
/launcher/modplatform/flame/FlameModIndex.cpp
:@@ -56,7 +56,14 @@ void FlameMod::loadIndexedPackVersions(ModPlatform::IndexedPack& pack, file.fileId = Json::requireInteger(obj, "id"); file.date = Json::requireString(obj, "fileDate"); file.version = Json::requireString(obj, "displayName"); - file.downloadUrl = Json::requireString(obj, "downloadUrl"); + file.downloadUrl = Json::ensureString(obj, "downloadUrl", ""); + if (file.downloadUrl.isEmpty()) { + file.downloadUrl = QString("https://media.forgecdn.net/files/%1/%2/%3") + .arg(QString::number(QString::number(file.fileId.toInt()).leftRef(4).toInt()) + ,QString::number(QString::number(file.fileId.toInt()).rightRef(3).toInt()) + ,QUrl::toPercentEncoding(file.fileName)); + } + file.fileName = Json::requireString(obj, "fileName"); unsortedVersions.append(file);
- Edit
/launcher/modplatform/flame/FlamePackIndex.cpp
:@@ -67,10 +67,14 @@ void Flame::loadIndexedPackVersions(Flame::IndexedPack& pack, QJsonArray& arr) file.version = Json::requireString(version, "displayName"); file.downloadUrl = Json::ensureString(version, "downloadUrl"); - // only add if we have a download URL (third party distribution is enabled) - if (!file.downloadUrl.isEmpty()) { - unsortedVersions.append(file); + if (file.downloadUrl.isEmpty()) { + file.downloadUrl = QString("https://media.forgecdn.net/files/%1/%2/%3") + .arg(QString::number(QString::number(file.fileId).leftRef(4).toInt()) + ,QString::number(QString::number(file.fileId).rightRef(3).toInt()) + ,QUrl::toPercentEncoding(Json::requireString(version, "fileName"))); } + + unsortedVersions.append(file); } auto orderSortPredicate = [](const IndexedVersion& a, const IndexedVersion& b) -> bool { return a.fileId > b.fileId; };
- Build and install.
With these changes you should be able to download mods which have disallowed third party launchers. It will still warn you about manually downloading these mods, but the program will do it anyways.
Alternatively, you can download the exe I built and place it in a PolyMC 1.3.1 directory