fix: enable demo launch only on supported instances

e.g. >= 1.3.1 instances

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow
2022-09-15 19:23:58 -03:00
parent 1b2a7de4e2
commit 81e326571b
4 changed files with 31 additions and 1 deletions

View File

@ -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/"));

View File

@ -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<PackProfile> getPackProfile() const;