2022-07-08 00:31:24 +01:00
|
|
|
#include "VanillaInstanceCreationTask.h"
|
|
|
|
|
2022-09-26 10:50:31 +01:00
|
|
|
#include <utility>
|
|
|
|
|
2022-07-08 00:31:24 +01:00
|
|
|
#include "FileSystem.h"
|
|
|
|
#include "minecraft/MinecraftInstance.h"
|
|
|
|
#include "minecraft/PackProfile.h"
|
2022-07-14 20:13:23 +01:00
|
|
|
#include "settings/INISettingsObject.h"
|
2022-07-08 00:31:24 +01:00
|
|
|
|
2022-11-01 22:48:26 +00:00
|
|
|
VanillaCreationTask::VanillaCreationTask(BaseVersion::Ptr version, QString loader, BaseVersion::Ptr loader_version)
|
2023-08-14 17:16:53 +01:00
|
|
|
: InstanceCreationTask()
|
|
|
|
, m_version(std::move(version))
|
|
|
|
, m_using_loader(true)
|
|
|
|
, m_loader(std::move(loader))
|
|
|
|
, m_loader_version(std::move(loader_version))
|
2022-07-08 00:31:24 +01:00
|
|
|
{}
|
|
|
|
|
|
|
|
bool VanillaCreationTask::createInstance()
|
|
|
|
{
|
|
|
|
setStatus(tr("Creating instance from version %1").arg(m_version->name()));
|
|
|
|
|
|
|
|
auto instance_settings = std::make_shared<INISettingsObject>(FS::PathCombine(m_stagingPath, "instance.cfg"));
|
|
|
|
instance_settings->suspendSave();
|
|
|
|
{
|
|
|
|
MinecraftInstance inst(m_globalSettings, instance_settings, m_stagingPath);
|
|
|
|
auto components = inst.getPackProfile();
|
|
|
|
components->buildingFromScratch();
|
|
|
|
components->setComponentVersion("net.minecraft", m_version->descriptor(), true);
|
2023-08-14 17:16:53 +01:00
|
|
|
if (m_using_loader)
|
2022-07-08 00:31:24 +01:00
|
|
|
components->setComponentVersion(m_loader, m_loader_version->descriptor());
|
|
|
|
|
2022-07-14 20:13:23 +01:00
|
|
|
inst.setName(name());
|
2022-07-08 00:31:24 +01:00
|
|
|
inst.setIconKey(m_instIcon);
|
|
|
|
}
|
|
|
|
instance_settings->resumeSave();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|