| 146 | } |
| 147 | |
| 148 | void 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(); |
nothing calls this directly
no test coverage detected