| 265 | } |
| 266 | |
| 267 | void PackInstallTask::install() |
| 268 | { |
| 269 | setStatus(tr("Copying modpack files...")); |
| 270 | setProgress(0, m_files_to_copy.size()); |
| 271 | QCoreApplication::processEvents(); |
| 272 | |
| 273 | m_abortable = false; |
| 274 | |
| 275 | int i = 0; |
| 276 | for (auto iter = m_files_to_copy.constBegin(); iter != m_files_to_copy.constEnd(); iter++) { |
| 277 | auto& to = iter.key(); |
| 278 | auto& from = iter.value(); |
| 279 | FS::copy fileCopyOperation(from, to); |
| 280 | if (!fileCopyOperation()) { |
| 281 | qWarning() << "Failed to copy" << from << "to" << to; |
| 282 | emitFailed(tr("Failed to copy files")); |
| 283 | return; |
| 284 | } |
| 285 | |
| 286 | setProgress(i++, m_files_to_copy.size()); |
| 287 | QCoreApplication::processEvents(); |
| 288 | } |
| 289 | |
| 290 | setStatus(tr("Installing modpack...")); |
| 291 | QCoreApplication::processEvents(); |
| 292 | |
| 293 | auto instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg"); |
| 294 | auto instanceSettings = std::make_shared<INISettingsObject>(instanceConfigPath); |
| 295 | instanceSettings->suspendSave(); |
| 296 | |
| 297 | MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath); |
| 298 | auto components = instance.getPackProfile(); |
| 299 | components->buildingFromScratch(); |
| 300 | |
| 301 | for (auto target : m_version.targets) { |
| 302 | if (target.type == "game" && target.name == "minecraft") { |
| 303 | components->setComponentVersion("net.minecraft", target.version, true); |
| 304 | break; |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | for (auto target : m_version.targets) { |
| 309 | if (target.type != "modloader") |
| 310 | continue; |
| 311 | |
| 312 | if (target.name == "forge") { |
| 313 | components->setComponentVersion("net.minecraftforge", target.version); |
| 314 | } else if (target.name == "fabric") { |
| 315 | components->setComponentVersion("net.fabricmc.fabric-loader", target.version); |
| 316 | } else if (target.name == "neoforge") { |
| 317 | components->setComponentVersion("net.neoforged.neoforge", target.version); |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | // install any jar mods |
| 322 | QDir jarModsDir(FS::PathCombine(m_stagingPath, "minecraft", "jarmods")); |
| 323 | if (jarModsDir.exists()) { |
| 324 | QStringList jarMods; |
nothing calls this directly
no test coverage detected