From 81e326571bb31dc4a92f1dbe32cb3ec50ace71f8 Mon Sep 17 00:00:00 2001 From: flow Date: Thu, 15 Sep 2022 19:23:58 -0300 Subject: fix: enable demo launch only on supported instances e.g. >= 1.3.1 instances Signed-off-by: flow --- launcher/minecraft/MinecraftInstance.cpp | 8 ++++++++ launcher/minecraft/MinecraftInstance.h | 2 ++ 2 files changed, 10 insertions(+) (limited to 'launcher/minecraft') diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 9478b1b8..ab904fa2 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -245,6 +245,14 @@ QString MinecraftInstance::getLocalLibraryPath() const return libraries_dir.absolutePath(); } +bool MinecraftInstance::supportsDemo() const +{ + Version instance_ver { getPackProfile()->getComponentVersion("net.minecraft") }; + // Demo mode was introduced in 1.3.1: https://minecraft.fandom.com/wiki/Demo_mode#History + // FIXME: Due to Version constraints atm, this can't handle well non-release versions + return instance_ver >= Version("1.3.1"); +} + QString MinecraftInstance::jarModsDir() const { QDir jarmods_dir(FS::PathCombine(instanceRoot(), "jarmods/")); diff --git a/launcher/minecraft/MinecraftInstance.h b/launcher/minecraft/MinecraftInstance.h index d62ac655..fe39674a 100644 --- a/launcher/minecraft/MinecraftInstance.h +++ b/launcher/minecraft/MinecraftInstance.h @@ -69,6 +69,8 @@ public: // where the instance-local libraries should be QString getLocalLibraryPath() const; + /** Returns whether the instance, with its version, has support for demo mode. */ + [[nodiscard]] bool supportsDemo() const; ////// Profile management ////// std::shared_ptr getPackProfile() const; -- cgit