From 19797c0f585cae6c542fe771843b4d9619f1f076 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Thu, 29 Jan 2026 18:14:23 +0500 Subject: [PATCH 1/3] feat: abort launch when there are libraries missing Signed-off-by: Octol1ttle (cherry picked from commit d4817a566929f14a1439253950308b8017bc2d6f) --- launcher/CMakeLists.txt | 2 + launcher/minecraft/MinecraftInstance.cpp | 16 +++---- .../launch/EnsureOfflineLibraries.cpp | 43 +++++++++++++++++++ .../minecraft/launch/EnsureOfflineLibraries.h | 36 ++++++++++++++++ 4 files changed, 87 insertions(+), 10 deletions(-) create mode 100644 launcher/minecraft/launch/EnsureOfflineLibraries.cpp create mode 100644 launcher/minecraft/launch/EnsureOfflineLibraries.h diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index d2be54c99..de647455a 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -264,6 +264,8 @@ set(MINECRAFT_SOURCES minecraft/launch/ClaimAccount.h minecraft/launch/CreateGameFolders.cpp minecraft/launch/CreateGameFolders.h + minecraft/launch/EnsureOfflineLibraries.cpp + minecraft/launch/EnsureOfflineLibraries.h minecraft/launch/ModMinecraftJar.cpp minecraft/launch/ModMinecraftJar.h minecraft/launch/ExtractNatives.cpp diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 6904ed0bc..fe1619356 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -94,6 +94,8 @@ #include #include +#include "launch/EnsureOfflineLibraries.h" + #ifdef Q_OS_LINUX #include "MangoHud.h" #endif @@ -919,21 +921,13 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session, Minecr out << "Libraries:"; QStringList jars, nativeJars; profile->getLibraryFiles(runtimeContext(), jars, nativeJars, getLocalLibraryPath(), binRoot()); - auto printLibFile = [&out](const QString& path) { - QFileInfo info(path); - if (info.exists()) { - out << " " + path; - } else { - out << " " + path + " (missing)"; - } - }; for (auto file : jars) { - printLibFile(file); + out << " " + file; } out << ""; out << "Native libraries:"; for (auto file : nativeJars) { - printLibFile(file); + out << " " + file; } out << ""; } @@ -1172,6 +1166,8 @@ shared_qobject_ptr MinecraftInstance::createLaunchTask(AuthSessionPt for (auto t : createUpdateTask()) { process->appendStep(makeShared(pptr, t)); } + } else { + process->appendStep(makeShared(pptr, this)); } // if there are any jar mods diff --git a/launcher/minecraft/launch/EnsureOfflineLibraries.cpp b/launcher/minecraft/launch/EnsureOfflineLibraries.cpp new file mode 100644 index 000000000..8684fbdf6 --- /dev/null +++ b/launcher/minecraft/launch/EnsureOfflineLibraries.cpp @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2026 Octol1ttle + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "EnsureOfflineLibraries.h" + +#include "minecraft/PackProfile.h" + +EnsureOfflineLibraries::EnsureOfflineLibraries(LaunchTask* parent, MinecraftInstance* instance) : LaunchStep(parent), m_instance(instance) +{} + +void EnsureOfflineLibraries::executeTask() +{ + const auto profile = m_instance->getPackProfile()->getProfile(); + QStringList allJars; + profile->getLibraryFiles(m_instance->runtimeContext(), allJars, allJars, m_instance->getLocalLibraryPath(), m_instance->binRoot()); + for (const auto& jar : allJars) { + if (!QFileInfo::exists(jar)) { + emit logLine( + tr("This instance cannot be launched in offline mode because libraries have not been downloaded yet. Please try again in " + "online mode with a working Internet connection"), + MessageLevel::Fatal); + emitFailed("Required libraries are missing"); + return; + } + } + + emitSucceeded(); +} diff --git a/launcher/minecraft/launch/EnsureOfflineLibraries.h b/launcher/minecraft/launch/EnsureOfflineLibraries.h new file mode 100644 index 000000000..87c0536a3 --- /dev/null +++ b/launcher/minecraft/launch/EnsureOfflineLibraries.h @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2026 Octol1ttle + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include "launch/LaunchStep.h" +#include "minecraft/MinecraftInstance.h" + +class EnsureOfflineLibraries : public LaunchStep { + Q_OBJECT + + public: + explicit EnsureOfflineLibraries(LaunchTask* parent, MinecraftInstance* instance); + ~EnsureOfflineLibraries() override = default; + + void executeTask() override; + bool canAbort() const override { return false; } + + private: + MinecraftInstance* m_instance; +}; From af6e4445ad86a07599f6ebea53c96b36766b602b Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Thu, 29 Jan 2026 18:17:22 +0500 Subject: [PATCH 2/3] style: reorder includes Signed-off-by: Octol1ttle (cherry picked from commit 193840b237429f857847f9b4e22ab4bb988c5f2c) --- launcher/minecraft/MinecraftInstance.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index fe1619356..7fe183708 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -40,13 +40,6 @@ #include "BuildConfig.h" #include "Json.h" #include "QObjectPtr.h" -#include "minecraft/launch/AutoInstallJava.h" -#include "minecraft/launch/CreateGameFolders.h" -#include "minecraft/launch/ExtractNatives.h" -#include "minecraft/launch/PrintInstanceInfo.h" -#include "minecraft/update/AssetUpdateTask.h" -#include "minecraft/update/FMLLibrariesTask.h" -#include "minecraft/update/LibrariesTask.h" #include "settings/Setting.h" #include "settings/SettingsObject.h" @@ -63,13 +56,23 @@ #include "launch/steps/QuitAfterGameStop.h" #include "launch/steps/TextPrint.h" +#include "minecraft/launch/AutoInstallJava.h" #include "minecraft/launch/ClaimAccount.h" +#include "minecraft/launch/CreateGameFolders.h" +#include "minecraft/launch/EnsureOfflineLibraries.h" +#include "minecraft/launch/ExtractNatives.h" #include "minecraft/launch/LauncherPartLaunch.h" #include "minecraft/launch/ModMinecraftJar.h" +#include "minecraft/launch/PrintInstanceInfo.h" #include "minecraft/launch/ReconstructAssets.h" #include "minecraft/launch/ScanModFolders.h" #include "minecraft/launch/VerifyJavaInstall.h" +#include "minecraft/update/AssetUpdateTask.h" +#include "minecraft/update/FoldersTask.h" +#include "minecraft/update/LegacyFMLLibrariesTask.h" +#include "minecraft/update/LibrariesTask.h" + #include "java/JavaUtils.h" #include "icons/IconList.h" @@ -84,7 +87,6 @@ #include "AssetsUtils.h" #include "MinecraftLoadAndCheck.h" #include "PackProfile.h" -#include "minecraft/update/FoldersTask.h" #include "tools/BaseProfiler.h" @@ -94,8 +96,6 @@ #include #include -#include "launch/EnsureOfflineLibraries.h" - #ifdef Q_OS_LINUX #include "MangoHud.h" #endif From a33b4297adc2feefd0781904cded33ae6280d029 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Thu, 29 Jan 2026 19:54:02 +0500 Subject: [PATCH 3/3] improve wording Signed-off-by: Octol1ttle (cherry picked from commit ffd1e7bc333ae0c10d078f95ae5f09e1a4f1f180) --- launcher/minecraft/MinecraftInstance.cpp | 2 +- launcher/minecraft/launch/EnsureOfflineLibraries.cpp | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 7fe183708..f8924579a 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -69,8 +69,8 @@ #include "minecraft/launch/VerifyJavaInstall.h" #include "minecraft/update/AssetUpdateTask.h" +#include "minecraft/update/FMLLibrariesTask.h" #include "minecraft/update/FoldersTask.h" -#include "minecraft/update/LegacyFMLLibrariesTask.h" #include "minecraft/update/LibrariesTask.h" #include "java/JavaUtils.h" diff --git a/launcher/minecraft/launch/EnsureOfflineLibraries.cpp b/launcher/minecraft/launch/EnsureOfflineLibraries.cpp index 8684fbdf6..59801a1d0 100644 --- a/launcher/minecraft/launch/EnsureOfflineLibraries.cpp +++ b/launcher/minecraft/launch/EnsureOfflineLibraries.cpp @@ -30,10 +30,9 @@ void EnsureOfflineLibraries::executeTask() profile->getLibraryFiles(m_instance->runtimeContext(), allJars, allJars, m_instance->getLocalLibraryPath(), m_instance->binRoot()); for (const auto& jar : allJars) { if (!QFileInfo::exists(jar)) { - emit logLine( - tr("This instance cannot be launched in offline mode because libraries have not been downloaded yet. Please try again in " - "online mode with a working Internet connection"), - MessageLevel::Fatal); + emit logLine(tr("This instance cannot be launched because some libraries are missing or have not been downloaded yet. Please " + "try again in online mode with a working Internet connection"), + MessageLevel::Fatal); emitFailed("Required libraries are missing"); return; }