MinecraftInstance
Concrete implementation of BaseInstance for Minecraft instances.
Class: MinecraftInstance
Header: launcher/minecraft/MinecraftInstance.h
Inherits: BaseInstance
Constructor
MinecraftInstance (
SettingsObject * globalSettings,
std ::unique_ptr < SettingsObject > settings,
const QString & rootDir
);
Directory Structure
Returns the Minecraft game directory (.minecraft).
Returns the binary directory for Minecraft executables.
Returns the mods root directory.
Returns the jar mods directory.
Returns the resource packs directory.
Returns the texture packs directory.
Returns the shader packs directory.
Returns the data packs directory.
Returns the saves/worlds directory.
Returns the libraries directory.
Returns the resources directory.
Path Helpers
QDir jarmodsPath () const ;
QDir librariesPath () const ;
QDir versionsPath () const ;
QString instanceConfigFolder () const override ;
QString getNativePath () const ;
QString getLocalLibraryPath () const ;
Resource Management
Access various resource folder models:
Returns the loader mods folder model.
Returns the core mods folder model.
Returns the nil mods folder model.
Returns the resource packs folder model.
Returns the texture packs folder model.
Returns the shader packs folder model.
Returns the data packs folder model.
resourceLists()
QList<ResourceFolderModel*>
Returns all resource folder models.
Profile Management
Returns the component/version profile for this instance.
Launch Configuration
Create Tasks
Arguments
Environment
QList < Task :: Ptr > createUpdateTask () override ;
Creates update tasks for the instance (downloads libraries, assets, etc.). LaunchTask * createLaunchTask (
AuthSessionPtr account ,
MinecraftTarget :: Ptr targetToJoin
) override ;
Creates a launch task for starting the game. QStringList extraArguments () override ;
QStringList javaArguments ();
Returns additional JVM and game arguments. QStringList processMinecraftArgs (
AuthSessionPtr account ,
MinecraftTarget :: Ptr targetToJoin
) const ;
Processes Minecraft arguments with variable substitution. QProcessEnvironment createEnvironment () override ;
QProcessEnvironment createLaunchEnvironment () override ;
Creates environment variables for launching processes. QMap < QString , QString > getVariables () override ;
Returns variables for launch command substitution.
Java Configuration
Returns the Java version required by this instance.
QStringList getClassPath ();
QStringList getNativeJars ();
QString getMainClass () const ;
Utility Methods
Returns true if the instance supports Minecraft demo mode.
Returns list of jar mods in the instance.
Returns the launcher type/wrapper to use.
Returns true if online fixes should be applied.
Example Usage
#include "minecraft/MinecraftInstance.h"
#include "Application.h"
// Get a Minecraft instance
BaseInstance * base = APPLICATION -> instances ()-> getInstanceById ( "my_instance" );
MinecraftInstance * inst = dynamic_cast < MinecraftInstance *> (base);
if (inst) {
// Access resource lists
ModFolderModel * mods = inst -> loaderModList ();
qDebug () << "Mods:" << mods -> size ();
// Get directories
qDebug () << "Mods dir:" << inst -> modsRoot ();
qDebug () << "World dir:" << inst -> worldDir ();
qDebug () << "Resource packs:" << inst -> resourcePacksDir ();
// Work with pack profile
PackProfile * profile = inst -> getPackProfile ();
qDebug () << "Minecraft version:" << profile -> getComponentVersion ( "net.minecraft" );
// Create launch task
AuthSessionPtr session = /* get account session */ ;
LaunchTask * task = inst -> createLaunchTask (session, nullptr );
connect (task, & Task ::finished, [ task ]() {
qDebug () << "Launch task finished" ;
});
task -> start ();
}
PackProfile
Manages the component profile for a Minecraft instance (versions, mods, loaders).
Class: PackProfile
Header: launcher/minecraft/PackProfile.h
Inherits: QAbstractListModel
Constructor
explicit PackProfile (MinecraftInstance * instance);
Component Management
getComponent(const QString& id)
Returns a component by its unique ID (e.g., “net.minecraft”, “net.fabricmc.fabric-loader”).
getComponent(size_t index)
Returns a component by its index in the profile.
appendComponent(ComponentPtr component)
Adds a component to the profile.
Version Management
getComponentVersion(const QString& uid)
Returns the version string for a component.
setComponentVersion(const QString& uid, const QString& version, bool important)
Sets the version for a component. Returns true on success.
void setOldConfigVersion ( const QString & uid , const QString & version );
Sets legacy version mapping from instance config.
Installation
Jar Mods
Components
Agents
void installJarMods ( QStringList selectedFiles );
Installs jar mods to the instance. void installCustomJar ( QString selectedFile );
Installs a custom jar as the main game jar. bool installComponents ( QStringList selectedFiles );
Installs Prism/MultiMC component files. bool installEmpty ( const QString & uid , const QString & name );
Creates an empty component with the given UID. void installAgents ( QStringList selectedFiles );
Installs Java agent files to the instance.
Component Operations
enum MoveDirection { MoveUp , MoveDown };
move(int index, MoveDirection direction)
Moves a component up or down in the load order.
Removes a component by index. Returns true on success.
remove(const QString& id)
Removes a component by ID. Returns true on success.
Customizes a component (creates editable patch). Returns true on success.
Reverts a customized component to its base version. Returns true on success.
Profile Operations
struct Result {
bool success;
QString error;
operator bool () const { return success; }
static Result Success () { return { true , "" }; }
static Result Error ( const QString & errorMessage ) { return { false , errorMessage }; }
};
reload(Net::Mode netmode)
Reloads the component list and resolves dependencies.
resolve(Net::Mode netmode)
Resolves component dependencies without reloading.
Saves the profile immediately (normally saves are scheduled).
Launch Profile
getProfile()
std::shared_ptr<LaunchProfile>
Returns the computed launch profile after resolving all components.
invalidateLaunchProfile()
Marks the launch profile as invalid, requiring recomputation.
Mod Loader Detection
getModLoaders()
std::optional<ModPlatform::ModLoaderTypes>
Returns the active mod loader types (Forge, Fabric, Quilt, NeoForge).
getSupportedModLoaders()
std::optional<ModPlatform::ModLoaderTypes>
Returns supported mod loaders including compatible ones (e.g., Quilt supports Fabric).
getModLoadersList()
QList<ModPlatform::ModLoaderType>
Returns list of individual mod loader types.
Model Columns
enum Columns {
NameColumn = 0 ,
VersionColumn ,
NUM_COLUMNS
};
Signals
signals:
void minecraftChanged ();
Example Usage
#include "minecraft/PackProfile.h"
#include "minecraft/MinecraftInstance.h"
MinecraftInstance * inst = /* ... */ ;
PackProfile * profile = inst -> getPackProfile ();
// Get Minecraft version
QString mcVersion = profile -> getComponentVersion ( "net.minecraft" );
qDebug () << "Minecraft version:" << mcVersion;
// Change Minecraft version
if ( profile -> setComponentVersion ( "net.minecraft" , "1.20.1" , true )) {
qDebug () << "Version changed successfully" ;
}
// Install Fabric
if ( profile -> installEmpty ( "net.fabricmc.fabric-loader" , "Fabric Loader" )) {
profile -> setComponentVersion ( "net.fabricmc.fabric-loader" , "0.15.0" );
}
// Check mod loaders
auto loaders = profile -> getModLoaders ();
if ( loaders . has_value ()) {
qDebug () << "Has mod loader installed" ;
}
// Reload profile with network access
auto result = profile -> reload ( Net :: Mode ::Online);
if (result) {
qDebug () << "Profile reloaded successfully" ;
} else {
qDebug () << "Error:" << result . error ;
}
// Get component by ID
ComponentPtr mc = profile -> getComponent ( "net.minecraft" );
if (mc) {
qDebug () << "Component name:" << mc -> getName ();
}