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: Uuid

Instance UUID.

Defaults to Uuid::new_v4().

§name: String

Name of the instance.

§description: Option<String>

Optional description of the instance.

§version: String

Minecraft version identifier for this instance.

§instance_path: PathBuf

Path for the instance folder. This path contains the .minecraftfolder and some other metadata.

§libraries_path: PathBuf

Path for the libraries.

§assets_path: PathBuf

Path for the assets.

§fullscreen: bool

Enables fullscreen. Overwrites the custom window size.

Defaults to false.

§enable_custom_window_size: bool

Enables 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: u32

Custom game window width. Used when enable_custom_window_size is enabled.

Defaults to 1280.

§custom_height: u32

Custom game window height. Used when enable_custom_window_size is enabled.

Defaults to 720.

§enable_custom_memory: bool

Enables 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: u32

JVM 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: u32

JVM 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: bool

Flag whether the instance was installed.

Defaults to false.

§created: OffsetDateTime

Created timestamp.

Defaults to OffsetDateTime::now_utc().

§fabric_version: Option<String>
Available on crate feature fabric only.

Fabric loader version that is used by this instance.

Defaults to None.

Implementations§

Available on crate feature backup only.

Imports an instance from an archive file.

Path to the instance folder.

Path to the .minecraft folder.

Path to the libraries folder.

Path to the assets folder.

Path to the natives folder.

Path to the resources folder.

Path to the asset indexes folder.

Path to the log configs folder.

Path to the version data JSON file.

Available on crate feature fabric only.

Path to the version data JSON file.

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.

Available on crate feature log-files only.

Loads all log files from this instance.

Available on crate feature resourcepacks only.

Path to the .minecraft/resourcepacks or .minecraft/texturepacks folder.

Available on crate feature resourcepacks only.

Gets whether the instance uses resource- or texturepacks.

Available on crate feature resourcepacks only.

Loads all resourcepacks from this instance.

Available on crate feature 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.

Available on crate feature save-games only.

Path to the .minecraft/saves folder.

Available on crate feature save-games only.

Loads all save games from this instance.

Available on crate feature backup only.

Imports a save game from an exported archive. Parses the imported save game and returns None if parsing fails.

Available on crate feature screenshots only.

Loads all screenshots from this instance.

Available on crate feature servers only.

Path to the .minecraft/servers.dat file.

Available on crate feature servers only.

Loads all screenshots from this instance.

Available on crate feature servers only.

Adds a new server to this instance. Also sets the correct path to this instances servers.dat file.

Available on crate feature 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.

Performs a full installation of Minecraft.

Includes

  • Saving version data
  • Saving fabric version data
  • Libraries
  • Fabric libraries (when enabled)
  • Assets / Resources
  • Log config
  • Client

Builds the launch command for this instance. Uses fabric when enabled. The instance needs to be properly installed.

Launches the instance as a child process. Uses fabric when enabled. Game process exits if parent exits.

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.

Available on crate feature loader-mods only.

Path to the .minecraft/mods folder.

Available on crate feature loader-mods only.

Loads all log files from this instance.

Available on crate feature loader-mods only.

Adds a loader mod.

Returns None when src is not a valid resourcepack.

Available on crate feature shaderpacks only.

Path to the .minecraft/resourcepacks or .minecraft/texturepacks folder.

Available on crate feature shaderpacks only.

Loads all shaderpacks from this instance.

Available on crate feature shaderpacks only.

Adds a shaderpack.

Returns None when src is not a valid shaderpack.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more