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

Method install

launcher/modplatform/legacy_ftb/PackInstallTask.cpp:152–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152void PackInstallTask::install()
153{
154 progress(3, 4);
155 setStatus(tr("Installing modpack"));
156 QDir unzipMcDir(m_stagingPath + "/unzip/minecraft");
157 if(unzipMcDir.exists())
158 {
159 //ok, found minecraft dir, move contents to instance dir
160 if(!QDir().rename(m_stagingPath + "/unzip/minecraft", m_stagingPath + "/.minecraft"))
161 {
162 emitFailed(tr("Failed to move unzipped Minecraft!"));
163 return;
164 }
165 }
166
167 QString instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg");
168 auto instanceSettings = std::make_shared<INISettingsObject>(instanceConfigPath);
169 instanceSettings->suspendSave();
170
171 MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
172 auto components = instance.getPackProfile();
173 components->buildingFromScratch();
174 components->setComponentVersion("net.minecraft", m_pack.mcVersion, true);
175
176 bool fallback = true;
177
178 //handle different versions
179 QFile packJson(m_stagingPath + "/.minecraft/pack.json");
180 QDir jarmodDir = QDir(m_stagingPath + "/unzip/instMods");
181 if(packJson.exists())
182 {
183 packJson.open(QIODevice::ReadOnly | QIODevice::Text);
184 QJsonDocument doc = QJsonDocument::fromJson(packJson.readAll());
185 packJson.close();
186
187 //we only care about the libs
188 QJsonArray libs = doc.object().value("libraries").toArray();
189
190 foreach (const QJsonValue &value, libs)
191 {
192 QString nameValue = value.toObject().value("name").toString();
193 if(!nameValue.startsWith("net.minecraftforge"))
194 {
195 continue;
196 }
197
198 GradleSpecifier forgeVersion(nameValue);
199
200 components->setComponentVersion("net.minecraftforge", forgeVersion.version().replace(m_pack.mcVersion, "").replace("-", ""));
201 packJson.remove();
202 fallback = false;
203 break;
204 }
205
206 }
207
208 if(jarmodDir.exists())
209 {

Callers

nothing calls this directly

Calls 15

PathCombineFunction · 0.85
fromJsonFunction · 0.85
deletePathFunction · 0.85
existsMethod · 0.80
renameMethod · 0.80
suspendSaveMethod · 0.80
getPackProfileMethod · 0.80
buildingFromScratchMethod · 0.80
setComponentVersionMethod · 0.80
openMethod · 0.80
objectMethod · 0.80
installJarModsMethod · 0.80

Tested by

no test coverage detected