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

Method executeTask

launcher/minecraft/launch/ModMinecraftJar.cpp:43–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 12

ensureFolderPathExistsFunction · 0.85
getJarModsMethod · 0.80
binRootMethod · 0.80
getPackProfileMethod · 0.80
getProfileMethod · 0.80
getMainJarMethod · 0.80
getApplicableFilesMethod · 0.80
getLocalLibraryPathMethod · 0.80
QDirClass · 0.50
instanceMethod · 0.45
sizeMethod · 0.45
runtimeContextMethod · 0.45

Tested by

no test coverage detected