| 1046 | } |
| 1047 | |
| 1048 | shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr session, MinecraftTarget::Ptr targetToJoin) |
| 1049 | { |
| 1050 | updateRuntimeContext(); |
| 1051 | // FIXME: get rid of shared_from_this ... |
| 1052 | auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(shared_from_this())); |
| 1053 | auto pptr = process.get(); |
| 1054 | |
| 1055 | APPLICATION->icons()->saveIcon(iconKey(), FS::PathCombine(gameRoot(), "icon.png"), "PNG"); |
| 1056 | |
| 1057 | // print a header |
| 1058 | { |
| 1059 | process->appendStep(makeShared<TextPrint>(pptr, "Minecraft folder is:\n" + gameRoot() + "\n\n", MessageLevel::Launcher)); |
| 1060 | } |
| 1061 | |
| 1062 | // create the .minecraft folder and server-resource-packs (workaround for Minecraft bug MCL-3732) |
| 1063 | { |
| 1064 | process->appendStep(makeShared<CreateGameFolders>(pptr)); |
| 1065 | } |
| 1066 | |
| 1067 | if (!targetToJoin && settings()->get("JoinServerOnLaunch").toBool()) { |
| 1068 | QString fullAddress = settings()->get("JoinServerOnLaunchAddress").toString(); |
| 1069 | if (!fullAddress.isEmpty()) { |
| 1070 | targetToJoin.reset(new MinecraftTarget(MinecraftTarget::parse(fullAddress, false))); |
| 1071 | } else { |
| 1072 | QString world = settings()->get("JoinWorldOnLaunch").toString(); |
| 1073 | if (!world.isEmpty()) { |
| 1074 | targetToJoin.reset(new MinecraftTarget(MinecraftTarget::parse(world, true))); |
| 1075 | } |
| 1076 | } |
| 1077 | } |
| 1078 | |
| 1079 | if (targetToJoin && targetToJoin->port == 25565) { |
| 1080 | // Resolve server address to join on launch |
| 1081 | auto step = makeShared<LookupServerAddress>(pptr); |
| 1082 | step->setLookupAddress(targetToJoin->address); |
| 1083 | step->setOutputAddressPtr(targetToJoin); |
| 1084 | process->appendStep(step); |
| 1085 | } |
| 1086 | |
| 1087 | // load meta |
| 1088 | { |
| 1089 | auto mode = session->status != AuthSession::PlayableOffline ? Net::Mode::Online : Net::Mode::Offline; |
| 1090 | process->appendStep(makeShared<TaskStepWrapper>(pptr, makeShared<MinecraftLoadAndCheck>(this, mode))); |
| 1091 | } |
| 1092 | |
| 1093 | // check java |
| 1094 | { |
| 1095 | process->appendStep(makeShared<AutoInstallJava>(pptr)); |
| 1096 | process->appendStep(makeShared<CheckJava>(pptr)); |
| 1097 | } |
| 1098 | |
| 1099 | // run pre-launch command if that's needed |
| 1100 | if (getPreLaunchCommand().size()) { |
| 1101 | auto step = makeShared<PreLaunchCommand>(pptr); |
| 1102 | step->setWorkingDirectory(gameRoot()); |
| 1103 | process->appendStep(step); |
| 1104 | } |
| 1105 |
nothing calls this directly
no test coverage detected