pub struct Instance {
Show 19 fields pub uuid: Uuid, pub name: String, pub description: String, pub version: String, pub instance_path: String, pub libraries_path: String, pub assets_path: String, pub use_fullscreen: bool, pub enable_window_size: bool, pub window_width: u32, pub window_height: u32, pub enable_memory: bool, pub min_memory: u32, pub max_memory: u32, pub enable_java_exec: bool, pub java_exec: String, pub enable_jvm_args: bool, pub jvm_args: String, pub created: OffsetDateTime,
}
Expand description

A single instance of Minecraft with defined locations for libraries, assets and the .minecraft folder. An instance can be configured to pass different arguments to the game when launching like window size.

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::Uuid::new_v4() when using InstanceBuilder.

name: String

Name of the instance.

description: String

Description of the instance.

Default to an empty string when using InstanceBuilder.

version: String

Minecraft version used by the instance.

instance_path: String

Path for the instance. This path contains the .minecraft folder and the version data JSON.

libraries_path: String

Path for libraries.

assets_path: String

Path for assets.

use_fullscreen: bool

Launches the game in fullscreen mode. When set to true, the window size is ignored.

Defaults to false when using InstanceBuilder.

enable_window_size: bool

Enables a custom resolution for the game window. Only has an effect when game is not launched in fullscreen mode.

Defaults to false when using InstanceBuilder.

window_width: u32

Game window width. Used when enable_window_size is set to true.

Defaults to 1280 when using InstanceBuilder.

window_height: u32

Game window height. Used when enable_window_size is set to true.

Defaults to 720 when using InstanceBuilder.

enable_memory: bool

Enables custom memory JVM arguments.

Defaults to false when using InstanceBuilder.

min_memory: u32

JVM initial heap size in megabytes. Adds the -Xms option to the command. Gets added before jvm_args.

Defaults to 1024 when using InstanceBuilder.

max_memory: u32

JVM max heap size in megabytes. Adds the -Xmx option to the command. Gets added before jvm_args`.

Defaults to 2048 when using InstanceBuilder.

enable_java_exec: bool

Enables a custom java executable. Launching an instance tries to use the instances java_exec when enabled, then tries java_exec for

Defaults to false when using InstanceBuilder.

java_exec: String

Java executable used to launch minecraft.

Defaults to java when using InstanceBuilder.

enable_jvm_args: bool

Enables custom JVM arguments. When disabled and the version data provides JVM arguments, the arguments from the version data are used. When enabled, arguments from version data are ignored.

Defaults to false when using InstanceBuilder.

jvm_args: String

Custom JVM arguments.

Defaults to and empty string when using InstanceBuilder.

created: OffsetDateTime

Created timestamp.

Defaults to time::OffsetDateTime::now_utc() when using InstanceBuilder.

Implementations

Saves the asset index JSON to disk.

Read the asset index JSON from disk. This does not download the index if it does not exist.

Installs all the needed assets. Installs the assets as resources for older versions.

Needs to be called after the asset index is saved to disk. Returns true if cancelled.

Checks if the instance is already installed.

Currently only checks

  • Version data exists and
  • Minecraft client exists

Installs the Minecraft client.

Needs to be called after version data is saved to disk. Returns true if cancelled.

Installs the all needed libraries. Also extracts natives.

Needs to be called after version data is saved to disk. Returns true if cancelled.

Installs the log config file.

Needs to be called after version data is saved to disk. Returns true if cancelled.

Saves the version data JSON to disk.

Read the version data JSON from disk. This does not download the index if it does not exist.

Provides the channel needed for full_install(). Eliminates the need to use crossbeam_channel to get the needed channel.

Does a full installation of Minecraft.

Includes:

  • Version Data
  • Asset Index
  • Libraries
  • Assets or Resources
  • Log Config
  • Client
let (sender, receiver) = Instance::update_channel();
let cancel = Arc::new(AtomicBool::new(false));

thread::spawn(move || {
    instance.full_install(sender, cancel)
});

while let Ok(update) = receiver.recv() {
    println!("{:#?}", update);
}

Builds the command that launches the game. It is required to install all game resources or the game will exit immediately.

This function enables to consume to make modifications to the command.

Launches the game. It is required to install all game resources or the game will exit immediately. Returns a handle to the game process.

Path to the instance. This path contains the version data JSON and the .minecraft folder.

Path to the .minecraft folder.

Path to the game libraries. Path can be shared with other instances of same/different version..

Path to the game assets.

Path to the natives.

Path to the game resources.

Path to the version data JSON file.

Path to the asset index JSON file.

Path to the log config XML file.

Available on crate feature resourcepacks only.

Loads all resourcepacks from this instance.

Available on crate feature saves only.

Loads all saves from this instance.

Available on crate feature screenshots only.

Loads all screenshots from this instance.

Available on crate feature servers only.

Loads all servers from this instance.

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

Converts to this type from the input type.

Converts to this type from the input type.

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