| 13 | m_inst = inst; |
| 14 | } |
| 15 | void FMLLibrariesTask::executeTask() |
| 16 | { |
| 17 | // Get the mod list |
| 18 | MinecraftInstance *inst = (MinecraftInstance *)m_inst; |
| 19 | auto components = inst->getPackProfile(); |
| 20 | auto profile = components->getProfile(); |
| 21 | |
| 22 | if (!profile->hasTrait("legacyFML")) |
| 23 | { |
| 24 | emitSucceeded(); |
| 25 | return; |
| 26 | } |
| 27 | |
| 28 | QString version = components->getComponentVersion("net.minecraft"); |
| 29 | auto &fmlLibsMapping = g_VersionFilterData.fmlLibsMapping; |
| 30 | if (!fmlLibsMapping.contains(version)) |
| 31 | { |
| 32 | emitSucceeded(); |
| 33 | return; |
| 34 | } |
| 35 | |
| 36 | auto &libList = fmlLibsMapping[version]; |
| 37 | |
| 38 | // determine if we need some libs for FML or forge |
| 39 | setStatus(tr("Checking for FML libraries...")); |
| 40 | if(!components->getComponent("net.minecraftforge")) |
| 41 | { |
| 42 | emitSucceeded(); |
| 43 | return; |
| 44 | } |
| 45 | |
| 46 | // now check the lib folder inside the instance for files. |
| 47 | for (auto &lib : libList) |
| 48 | { |
| 49 | QFileInfo libInfo(FS::PathCombine(inst->libDir(), lib.filename)); |
| 50 | if (libInfo.exists()) |
| 51 | continue; |
| 52 | fmlLibsToProcess.append(lib); |
| 53 | } |
| 54 | |
| 55 | // if everything is in place, there's nothing to do here... |
| 56 | if (fmlLibsToProcess.isEmpty()) |
| 57 | { |
| 58 | emitSucceeded(); |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | // download missing libs to our place |
| 63 | setStatus(tr("Downloading FML libraries...")); |
| 64 | auto dljob = new NetJob("FML libraries", APPLICATION->network()); |
| 65 | auto metacache = APPLICATION->metacache(); |
| 66 | for (auto &lib : fmlLibsToProcess) |
| 67 | { |
| 68 | auto entry = metacache->resolveEntry("fmllibs", lib.filename); |
| 69 | QString urlString = BuildConfig.FMLLIBS_BASE_URL + lib.filename; |
| 70 | dljob->addNetAction(Net::Download::makeCached(QUrl(urlString), entry)); |
| 71 | } |
| 72 |
nothing calls this directly
no test coverage detected