MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / install

Method install

launcher/modplatform/legacy_ftb/PackInstallTask.cpp:133–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133void PackInstallTask::install()
134{
135 setStatus(tr("Installing modpack"));
136 progress(3, 4);
137 QDir unzipMcDir(m_stagingPath + "/unzip/minecraft");
138 if (unzipMcDir.exists()) {
139 // ok, found minecraft dir, move contents to instance dir
140 if (!FS::move(m_stagingPath + "/unzip/minecraft", m_stagingPath + "/minecraft")) {
141 emitFailed(tr("Failed to move unpacked Minecraft!"));
142 return;
143 }
144 }
145
146 QString instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg");
147 auto instanceSettings = std::make_shared<INISettingsObject>(instanceConfigPath);
148 instanceSettings->suspendSave();
149
150 MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
151 auto components = instance.getPackProfile();
152 components->buildingFromScratch();
153 components->setComponentVersion("net.minecraft", m_pack.mcVersion, true);
154
155 bool fallback = true;
156
157 // handle different versions
158 QFile packJson(m_stagingPath + "/minecraft/pack.json");
159 QDir jarmodDir = QDir(m_stagingPath + "/unzip/instMods");
160 if (packJson.exists()) {
161 packJson.open(QIODevice::ReadOnly | QIODevice::Text);
162 QJsonDocument doc = QJsonDocument::fromJson(packJson.readAll());
163 packJson.close();
164
165 // we only care about the libs
166 QJsonArray libs = doc.object().value("libraries").toArray();
167
168 foreach (const QJsonValue& value, libs) {
169 QString nameValue = value.toObject().value("name").toString();
170 if (!nameValue.startsWith("net.minecraftforge")) {
171 continue;
172 }
173
174 GradleSpecifier forgeVersion(nameValue);
175
176 components->setComponentVersion("net.minecraftforge", forgeVersion.version().replace(m_pack.mcVersion, "").replace("-", ""));
177 packJson.remove();
178 fallback = false;
179 break;
180 }
181 }
182
183 if (jarmodDir.exists()) {
184 qDebug() << "Found jarmods, installing...";
185
186 QStringList jarmods;
187 for (auto info : jarmodDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files)) {
188 qDebug() << "Jarmod:" << info.fileName();
189 jarmods.push_back(info.absoluteFilePath());
190 }

Callers 1

validateZIPResourcesMethod · 0.45

Calls 15

moveFunction · 0.85
PathCombineFunction · 0.85
deletePathFunction · 0.85
existsMethod · 0.80
suspendSaveMethod · 0.80
getPackProfileMethod · 0.80
buildingFromScratchMethod · 0.80
setComponentVersionMethod · 0.80
openMethod · 0.80
closeMethod · 0.80
valueMethod · 0.80
objectMethod · 0.80

Tested by

no test coverage detected