MCPcopy Create free account
hub / github.com/MultiMC/Launcher / install

Method install

launcher/modplatform/modpacksch/FTBPackInstallTask.cpp:148–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148void PackInstallTask::install()
149{
150 setStatus(tr("Copying modpack files"));
151
152 for (auto iter = filesToCopy.begin(); iter != filesToCopy.end(); iter++) {
153 auto &to = iter.key();
154 auto &from = iter.value();
155 FS::copy fileCopyOperation(from, to);
156 if(!fileCopyOperation()) {
157 qWarning() << "Failed to copy" << from << "to" << to;
158 emitFailed(tr("Failed to copy files"));
159 return;
160 }
161 }
162
163 setStatus(tr("Installing modpack"));
164
165 auto instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg");
166 auto instanceSettings = std::make_shared<INISettingsObject>(instanceConfigPath);
167 instanceSettings->suspendSave();
168 instanceSettings->registerSetting("InstanceType", "Legacy");
169 instanceSettings->set("InstanceType", "OneSix");
170
171 MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
172 auto components = instance.getPackProfile();
173 components->buildingFromScratch();
174
175 for(auto target : m_version.targets) {
176 if(target.type == "game" && target.name == "minecraft") {
177 components->setComponentVersion("net.minecraft", target.version, true);
178 break;
179 }
180 }
181
182 for(auto target : m_version.targets) {
183 if(target.type != "modloader") continue;
184
185 if(target.name == "forge") {
186 components->setComponentVersion("net.minecraftforge", target.version, true);
187 }
188 else if(target.name == "fabric") {
189 components->setComponentVersion("net.fabricmc.fabric-loader", target.version, true);
190 }
191 }
192
193 // install any jar mods
194 QDir jarModsDir(FS::PathCombine(m_stagingPath, "minecraft", "jarmods"));
195 if (jarModsDir.exists()) {
196 QStringList jarMods;
197
198 for (const auto& info : jarModsDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files)) {
199 jarMods.push_back(info.absoluteFilePath());
200 }
201
202 components->installJarMods(jarMods);
203 }
204
205 components->saveNow();

Callers

nothing calls this directly

Calls 15

PathCombineFunction · 0.85
keyMethod · 0.80
suspendSaveMethod · 0.80
getPackProfileMethod · 0.80
buildingFromScratchMethod · 0.80
setComponentVersionMethod · 0.80
existsMethod · 0.80
installJarModsMethod · 0.80
setIconKeyMethod · 0.80
resumeSaveMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected