MCPcopy Create free account
hub / github.com/MultiMC/Launcher / createLaunchTask

Method createLaunchTask

launcher/minecraft/MinecraftInstance.cpp:818–951  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

816}
817
818shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin)
819{
820 // FIXME: get rid of shared_from_this ...
821 auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(shared_from_this()));
822 auto pptr = process.get();
823
824 APPLICATION->icons()->saveIcon(iconKey(), FS::PathCombine(gameRoot(), "icon.png"), "PNG");
825
826 // print a header
827 {
828 process->appendStep(new TextPrint(pptr, "Minecraft folder is:\n" + gameRoot() + "\n\n", MessageLevel::Launcher));
829 }
830
831 // check java
832 {
833 process->appendStep(new CheckJava(pptr));
834 }
835
836 // check launch method
837 QStringList validMethods = {"LauncherPart", "DirectJava"};
838 QString method = launchMethod();
839 if(!validMethods.contains(method))
840 {
841 process->appendStep(new TextPrint(pptr, "Selected launch method \"" + method + "\" is not valid.\n", MessageLevel::Fatal));
842 return process;
843 }
844
845 // create the .minecraft folder and server-resource-packs (workaround for Minecraft bug MCL-3732)
846 {
847 process->appendStep(new CreateGameFolders(pptr));
848 }
849
850 if (!serverToJoin && m_settings->get("JoinServerOnLaunch").toBool())
851 {
852 QString fullAddress = m_settings->get("JoinServerOnLaunchAddress").toString();
853 serverToJoin.reset(new MinecraftServerTarget(MinecraftServerTarget::parse(fullAddress)));
854 }
855
856 if(serverToJoin && serverToJoin->port == 25565)
857 {
858 // Resolve server address to join on launch
859 auto *step = new LookupServerAddress(pptr);
860 step->setLookupAddress(serverToJoin->address);
861 step->setOutputAddressPtr(serverToJoin);
862 process->appendStep(step);
863 }
864
865 // run pre-launch command if that's needed
866 if(getPreLaunchCommand().size())
867 {
868 auto step = new PreLaunchCommand(pptr);
869 step->setWorkingDirectory(gameRoot());
870 process->appendStep(step);
871 }
872
873 // if we aren't in offline mode,.
874 if(session->status != AuthSession::PlayableOffline)
875 {

Callers

nothing calls this directly

Calls 15

PathCombineFunction · 0.85
saveIconMethod · 0.80
iconsMethod · 0.80
appendStepMethod · 0.80
setLookupAddressMethod · 0.80
setOutputAddressPtrMethod · 0.80
setCensorFilterMethod · 0.80
getMethod · 0.45
containsMethod · 0.45
toStringMethod · 0.45
resetMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected