Crates.io | mc-launcher-core |
lib.rs | mc-launcher-core |
version | 0.0.3 |
source | src |
created_at | 2023-12-03 15:21:39.242619 |
updated_at | 2024-01-17 09:25:25.898457 |
description | This is an mc launcher core written in Rust. |
homepage | https://github.com/Star-tears/mc-launcher-core |
repository | https://github.com/Star-tears/mc-launcher-core |
max_upload_size | |
id | 1056964 |
size | 204,114 |
This is an mc launcher core written in Rust.
You can use the functions provided by this library to create an mc launcher, offering only basic functionalities.
Use cargo add mc-launcher-core
to add it to your project.
Here's an example of launching the latest version of mc offline:
use std::process::Command;
use mc_launcher_core::{
auth::offline::get_offline_options,
command::get_minecraft_command,
install::install_minecraft_version,
types::CallbackDict,
utils::{get_latest_version, get_minecraft_directory},
};
fn main() {
let options = get_offline_options("Steve");
let latest_version = get_latest_version().unwrap().release;
let minecraft_directory = get_minecraft_directory();
let _ = install_minecraft_version(
&latest_version,
&minecraft_directory,
&CallbackDict::default(),
);
let minecraft_command_result = get_minecraft_command(
&get_latest_version().unwrap().release,
&minecraft_directory,
&options,
);
match minecraft_command_result {
Ok(minecraft_command) => {
// Start Minecraft
let mut cmd = Command::new(&minecraft_command[0])
.args(&minecraft_command[1..minecraft_command.len()])
.spawn()
.expect("Failed to start Minecraft");
let _ = cmd.wait();
}
Err(err) => {
eprintln!("Failed to get Minecraft command: {}", err);
}
}
}