| 41 | #include "minecraft/PackProfile.h" |
| 42 | |
| 43 | void ModMinecraftJar::executeTask() |
| 44 | { |
| 45 | auto m_inst = m_parent->instance(); |
| 46 | |
| 47 | if (!m_inst->getJarMods().size()) { |
| 48 | emitSucceeded(); |
| 49 | return; |
| 50 | } |
| 51 | // nuke obsolete stripped jar(s) if needed |
| 52 | if (!FS::ensureFolderPathExists(m_inst->binRoot())) { |
| 53 | emitFailed(tr("Couldn't create the bin folder for Minecraft.jar")); |
| 54 | } |
| 55 | |
| 56 | auto finalJarPath = QDir(m_inst->binRoot()).absoluteFilePath("minecraft.jar"); |
| 57 | if (!removeJar()) { |
| 58 | emitFailed(tr("Couldn't remove stale jar file: %1").arg(finalJarPath)); |
| 59 | } |
| 60 | |
| 61 | // create temporary modded jar, if needed |
| 62 | auto components = m_inst->getPackProfile(); |
| 63 | auto profile = components->getProfile(); |
| 64 | auto jarMods = m_inst->getJarMods(); |
| 65 | if (jarMods.size()) { |
| 66 | auto mainJar = profile->getMainJar(); |
| 67 | QStringList jars, temp1, temp2, temp3, temp4; |
| 68 | mainJar->getApplicableFiles(m_inst->runtimeContext(), jars, temp1, temp2, temp3, m_inst->getLocalLibraryPath()); |
| 69 | auto sourceJarPath = jars[0]; |
| 70 | if (!MMCZip::createModdedJar(sourceJarPath, finalJarPath, jarMods)) { |
| 71 | emitFailed(tr("Failed to create the custom Minecraft jar file.")); |
| 72 | return; |
| 73 | } |
| 74 | } |
| 75 | emitSucceeded(); |
| 76 | } |
| 77 | |
| 78 | void ModMinecraftJar::finalize() |
| 79 | { |
nothing calls this directly
no test coverage detected