pub struct Instance {Show 20 fields
pub uuid: Uuid,
pub name: String,
pub description: Option<String>,
pub version: String,
pub instance_path: PathBuf,
pub libraries_path: PathBuf,
pub assets_path: PathBuf,
pub fullscreen: bool,
pub enable_custom_window_size: bool,
pub custom_width: u32,
pub custom_height: u32,
pub enable_custom_memory: bool,
pub custom_min_memory: u32,
pub custom_max_memory: u32,
pub custom_java_executable: Option<String>,
pub custom_jvm_arguments: Option<String>,
pub environment_variables: Vec<(String, Option<String>)>,
pub installed: bool,
pub created: OffsetDateTime,
pub fabric_version: Option<String>,
}Expand description
A Minecraft instance with defined locations for installing libraries, assets and other game data. An instance enables multiple instances to be installed while sharing common data like assets and libraries.
An instance can be created using the builder pattern:
let instance: Instance = InstanceBuilder::default()
.name("Minecraft Instance".to_string())
.version("1.18.2".to_string())
.instance_path(".".to_string())
.libraries_path("./libraries".to_string())
.assets_path("./assets".to_string())
.build()?;
Fields§
§uuid: UuidInstance UUID.
Defaults to Uuid::new_v4().
name: StringName of the instance.
description: Option<String>Optional description of the instance.
version: StringMinecraft version identifier for this instance.
instance_path: PathBufPath for the instance folder.
This path contains the .minecraftfolder and some other metadata.
libraries_path: PathBufPath for the libraries.
assets_path: PathBufPath for the assets.
fullscreen: boolEnables fullscreen. Overwrites the custom window size.
Defaults to false.
enable_custom_window_size: boolEnables custom window size.
Takes effect when not launching in fullscreen.
The width and height can be configured with custom_width and custom_height.
Defaults to false.
custom_width: u32Custom game window width.
Used when enable_custom_window_size is enabled.
Defaults to 1280.
custom_height: u32Custom game window height.
Used when enable_custom_window_size is enabled.
Defaults to 720.
enable_custom_memory: boolEnables custom JVM memory restrictions.
The minimum and maximum can be configured with custom_min_memory and custom_max_memory.
Defaults to false.
custom_min_memory: u32JVM initial heap size in megabytes.
Adds the -Xms option to the command.
Gets added before custom_jvm_args.
Used when enable_custom_memory is enabled.
Defaults to 1024.
custom_max_memory: u32JVM max heap size in megabytes.
Adds the -Xmx option to the command. Gets added before custom_jvm_args. Used when enable_custom_memory` is enabled.
Defaults to 2048.
custom_java_executable: Option<String>Custom java executable.
Defaults to None.
custom_jvm_arguments: Option<String>Custom JVM arguments
Defaults to None.
environment_variables: Vec<(String, Option<String>)>Environment variables used for launching the game.
Defaults to vec![].
installed: boolFlag whether the instance was installed.
Defaults to false.
created: OffsetDateTimeCreated timestamp.
Defaults to OffsetDateTime::now_utc().
fabric_version: Option<String>fabric only.Fabric loader version that is used by this instance.
Defaults to None.
Implementations§
Source§impl Instance
impl Instance
Sourcepub fn instance_path(&self) -> PathBuf
pub fn instance_path(&self) -> PathBuf
Path to the instance folder.
Sourcepub fn dot_minecraft_path(&self) -> PathBuf
pub fn dot_minecraft_path(&self) -> PathBuf
Path to the .minecraft folder.
Sourcepub fn libraries_path(&self) -> PathBuf
pub fn libraries_path(&self) -> PathBuf
Path to the libraries folder.
Sourcepub fn assets_path(&self) -> PathBuf
pub fn assets_path(&self) -> PathBuf
Path to the assets folder.
Sourcepub fn natives_path(&self) -> PathBuf
pub fn natives_path(&self) -> PathBuf
Path to the natives folder.
Sourcepub fn resources_path(&self) -> PathBuf
pub fn resources_path(&self) -> PathBuf
Path to the resources folder.
Sourcepub fn asset_indexes_path(&self) -> PathBuf
pub fn asset_indexes_path(&self) -> PathBuf
Path to the asset indexes folder.
Sourcepub fn log_configs_path(&self) -> PathBuf
pub fn log_configs_path(&self) -> PathBuf
Path to the log configs folder.
Sourcepub fn version_data_path(&self) -> PathBuf
pub fn version_data_path(&self) -> PathBuf
Path to the version data JSON file.
Sourcepub fn fabric_version_data_path(&self) -> PathBuf
Available on crate feature fabric only.
pub fn fabric_version_data_path(&self) -> PathBuf
fabric only.Path to the version data JSON file.
Source§impl Instance
impl Instance
Sourcepub async fn remove(self) -> CobbleResult<()>
pub async fn remove(self) -> CobbleResult<()>
Removes the instance from disk.
Warning: This will permanently delete the following files:
- Resourcepacks
- Save games
- Screenshots
- Servers
- Shaderpacks
- Mods
It basically deletes the whole .minecraft folder.
Source§impl Instance
impl Instance
Sourcepub async fn load_log_files(&self) -> CobbleResult<Vec<LogFile>>
Available on crate feature log-files only.
pub async fn load_log_files(&self) -> CobbleResult<Vec<LogFile>>
log-files only.Loads all log files from this instance.
Source§impl Instance
impl Instance
Sourcepub fn resourcepacks_path(&self) -> PathBuf
Available on crate feature resourcepacks only.
pub fn resourcepacks_path(&self) -> PathBuf
resourcepacks only.Path to the .minecraft/resourcepacks or .minecraft/texturepacks folder.
Sourcepub fn resourcepacks_type(&self) -> ResourcepackType
Available on crate feature resourcepacks only.
pub fn resourcepacks_type(&self) -> ResourcepackType
resourcepacks only.Gets whether the instance uses resource- or texturepacks.
Sourcepub async fn load_resourcepacks(&self) -> CobbleResult<Vec<Resourcepack>>
Available on crate feature resourcepacks only.
pub async fn load_resourcepacks(&self) -> CobbleResult<Vec<Resourcepack>>
resourcepacks only.Loads all resourcepacks from this instance.
Sourcepub async fn add_resourcepack(
&self,
src: impl AsRef<Path>,
) -> CobbleResult<Option<Resourcepack>>
Available on crate feature resourcepacks only.
pub async fn add_resourcepack( &self, src: impl AsRef<Path>, ) -> CobbleResult<Option<Resourcepack>>
resourcepacks only.Adds a resourcepack. Tries to put it in the apropriate folder for the current version. If it fails to determine the correct folder, it assumes the instance uses resourcepacks.
Returns None when src is not a valid resourcepack.
Source§impl Instance
impl Instance
Sourcepub fn save_games_path(&self) -> PathBuf
Available on crate feature save-games only.
pub fn save_games_path(&self) -> PathBuf
save-games only.Path to the .minecraft/saves folder.
Sourcepub async fn load_save_games(&self) -> CobbleResult<Vec<SaveGame>>
Available on crate feature save-games only.
pub async fn load_save_games(&self) -> CobbleResult<Vec<SaveGame>>
save-games only.Loads all save games from this instance.
Sourcepub async fn import_save_game(
&self,
src: impl AsRef<Path>,
) -> CobbleResult<Option<SaveGame>>
Available on crate feature backup only.
pub async fn import_save_game( &self, src: impl AsRef<Path>, ) -> CobbleResult<Option<SaveGame>>
backup only.Imports a save game from an exported archive.
Parses the imported save game and returns None if parsing fails.
Source§impl Instance
impl Instance
Sourcepub async fn load_screenshots(&self) -> CobbleResult<Vec<Screenshot>>
Available on crate feature screenshots only.
pub async fn load_screenshots(&self) -> CobbleResult<Vec<Screenshot>>
screenshots only.Loads all screenshots from this instance.
Source§impl Instance
impl Instance
Sourcepub fn servers_file(&self) -> PathBuf
Available on crate feature servers only.
pub fn servers_file(&self) -> PathBuf
servers only.Path to the .minecraft/servers.dat file.
Sourcepub async fn load_servers(&self) -> CobbleResult<Vec<Server>>
Available on crate feature servers only.
pub async fn load_servers(&self) -> CobbleResult<Vec<Server>>
servers only.Loads all screenshots from this instance.
Sourcepub async fn add_server(&self, server: Server) -> CobbleResult<()>
Available on crate feature servers only.
pub async fn add_server(&self, server: Server) -> CobbleResult<()>
servers only.Adds a new server to this instance. Also sets the correct path to this instances servers.dat file.
Source§impl Instance
impl Instance
Sourcepub async fn export(
&self,
dest: impl AsRef<Path>,
offline: bool,
compression: u32,
) -> CobbleResult<()>
Available on crate feature backup only.
pub async fn export( &self, dest: impl AsRef<Path>, offline: bool, compression: u32, ) -> CobbleResult<()>
backup only.Exports the instance using a gzip compressed tar archive.
The compression is a level is an integer from 0-9 where 0 means “no
compression” and 9 means “take as long as you’d like”.
The offline parameter determines whether all needed assets are packaged as well.
Source§impl Instance
impl Instance
Sourcepub async fn full_installation(
&mut self,
parallel: u16,
retries: u16,
verify: bool,
update_sender: Sender<InstallationUpdate>,
) -> CobbleResult<()>
pub async fn full_installation( &mut self, parallel: u16, retries: u16, verify: bool, update_sender: Sender<InstallationUpdate>, ) -> CobbleResult<()>
Performs a full installation of Minecraft.
Includes
- Saving version data
- Saving fabric version data
- Libraries
- Fabric libraries (when enabled)
- Assets / Resources
- Log config
- Client
Source§impl Instance
impl Instance
Sourcepub async fn launch_command(
&self,
options: &LaunchOptions,
) -> CobbleResult<Command>
pub async fn launch_command( &self, options: &LaunchOptions, ) -> CobbleResult<Command>
Builds the launch command for this instance. Uses fabric when enabled. The instance needs to be properly installed.
Sourcepub async fn launch<I, O, E>(
&self,
options: &LaunchOptions,
stdin: I,
stdout: O,
stderr: E,
) -> CobbleResult<Child>
pub async fn launch<I, O, E>( &self, options: &LaunchOptions, stdin: I, stdout: O, stderr: E, ) -> CobbleResult<Child>
Launches the instance as a child process. Uses fabric when enabled. Game process exits if parent exits.
Sourcepub async fn detached_launch<I, O, E>(
&self,
options: &LaunchOptions,
stdin: I,
stdout: O,
stderr: E,
) -> CobbleResult<GameProcessHandle>
pub async fn detached_launch<I, O, E>( &self, options: &LaunchOptions, stdin: I, stdout: O, stderr: E, ) -> CobbleResult<GameProcessHandle>
Launches the instance as a detached process. Uses fabric when enabled. Game process does not exit if parent exits.
On unix platforms it is done by forking the process.
On windows it is done using the DETACHED_PROCESS and CREATE_NEW_PROCESS_GROUP flags.
Source§impl Instance
impl Instance
Sourcepub fn loader_mods_path(&self) -> PathBuf
Available on crate feature loader-mods only.
pub fn loader_mods_path(&self) -> PathBuf
loader-mods only.Path to the .minecraft/mods folder.
Sourcepub async fn load_loader_mods(&self) -> CobbleResult<Vec<LoaderMod>>
Available on crate feature loader-mods only.
pub async fn load_loader_mods(&self) -> CobbleResult<Vec<LoaderMod>>
loader-mods only.Loads all log files from this instance.
Sourcepub async fn add_loader_mod(
&self,
src: impl AsRef<Path>,
) -> CobbleResult<Option<LoaderMod>>
Available on crate feature loader-mods only.
pub async fn add_loader_mod( &self, src: impl AsRef<Path>, ) -> CobbleResult<Option<LoaderMod>>
loader-mods only.Adds a loader mod.
Returns None when src is not a valid resourcepack.
Source§impl Instance
impl Instance
Sourcepub fn shaderpacks_path(&self) -> PathBuf
Available on crate feature shaderpacks only.
pub fn shaderpacks_path(&self) -> PathBuf
shaderpacks only.Path to the .minecraft/resourcepacks or .minecraft/texturepacks folder.
Sourcepub async fn load_shaderpacks(&self) -> CobbleResult<Vec<Shaderpack>>
Available on crate feature shaderpacks only.
pub async fn load_shaderpacks(&self) -> CobbleResult<Vec<Shaderpack>>
shaderpacks only.Loads all shaderpacks from this instance.
Sourcepub async fn add_shaderpack(
&self,
src: impl AsRef<Path>,
) -> CobbleResult<Option<Shaderpack>>
Available on crate feature shaderpacks only.
pub async fn add_shaderpack( &self, src: impl AsRef<Path>, ) -> CobbleResult<Option<Shaderpack>>
shaderpacks only.Adds a shaderpack.
Returns None when src is not a valid shaderpack.