| 965 | } |
| 966 | |
| 967 | void PackInstallTask::install() |
| 968 | { |
| 969 | qDebug() << "PackInstallTask::install: " << QThread::currentThreadId(); |
| 970 | setStatus(tr("Installing modpack")); |
| 971 | |
| 972 | auto instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg"); |
| 973 | auto instanceSettings = std::make_shared<INISettingsObject>(instanceConfigPath); |
| 974 | instanceSettings->suspendSave(); |
| 975 | |
| 976 | MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath); |
| 977 | auto components = instance.getPackProfile(); |
| 978 | components->buildingFromScratch(); |
| 979 | |
| 980 | // Use a component to add libraries BEFORE Minecraft |
| 981 | if(!createLibrariesComponent(instance.instanceRoot(), components)) { |
| 982 | emitFailed(tr("Failed to create libraries component")); |
| 983 | return; |
| 984 | } |
| 985 | |
| 986 | // Minecraft |
| 987 | components->setComponentVersion("net.minecraft", m_version.minecraft, true); |
| 988 | |
| 989 | // Loader |
| 990 | if(m_version.loader.type == QString("forge")) |
| 991 | { |
| 992 | auto version = getVersionForLoader("net.minecraftforge"); |
| 993 | if(version == Q_NULLPTR) return; |
| 994 | |
| 995 | components->setComponentVersion("net.minecraftforge", version); |
| 996 | } |
| 997 | else if(m_version.loader.type == QString("fabric")) |
| 998 | { |
| 999 | auto version = getVersionForLoader("net.fabricmc.fabric-loader"); |
| 1000 | if(version == Q_NULLPTR) return; |
| 1001 | |
| 1002 | components->setComponentVersion("net.fabricmc.fabric-loader", version); |
| 1003 | } |
| 1004 | else if(m_version.loader.type != QString()) |
| 1005 | { |
| 1006 | emitFailed(tr("Unknown loader type: ") + m_version.loader.type); |
| 1007 | return; |
| 1008 | } |
| 1009 | |
| 1010 | for(const auto & componentUid : componentsToInstall.keys()) { |
| 1011 | auto version = componentsToInstall.value(componentUid); |
| 1012 | components->setComponentVersion(componentUid, version->version()); |
| 1013 | } |
| 1014 | |
| 1015 | components->installJarMods(jarmods); |
| 1016 | |
| 1017 | // Use a component to fill in the rest of the data |
| 1018 | // todo: use more detection |
| 1019 | if(!createPackComponent(instance.instanceRoot(), components)) { |
| 1020 | emitFailed(tr("Failed to create pack component")); |
| 1021 | return; |
| 1022 | } |
| 1023 | |
| 1024 | components->saveNow(); |
nothing calls this directly
no test coverage detected