MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / install

Method install

launcher/modplatform/atlauncher/ATLPackInstallTask.cpp:967–1033  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

965}
966
967void 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();

Callers

nothing calls this directly

Calls 15

PathCombineFunction · 0.85
QStringClass · 0.85
suspendSaveMethod · 0.80
getPackProfileMethod · 0.80
buildingFromScratchMethod · 0.80
instanceRootMethod · 0.80
setComponentVersionMethod · 0.80
installJarModsMethod · 0.80
setIconKeyMethod · 0.80
setManagedPackMethod · 0.80
resumeSaveMethod · 0.80
versionMethod · 0.45

Tested by

no test coverage detected