| Crates.io | late-java-core |
| lib.rs | late-java-core |
| version | 2.2.9 |
| created_at | 2025-10-19 04:48:23.877807+00 |
| updated_at | 2025-10-19 04:48:23.877807+00 |
| description | A Rust library for launching Minecraft Java Edition |
| homepage | |
| repository | https://github.com/luuxis/minecraft-java-core |
| max_upload_size | |
| id | 1889943 |
| size | 614,071 |
Una librería Rust para lanzar Minecraft Java Edition con soporte para mod loaders, autenticación Microsoft/Mojang/AZauth, y descarga automática de archivos.
Agrega esto a tu Cargo.toml:
[dependencies]
late-java-core = "2.2.9"
tokio = { version = "1.0", features = ["full"] }
use late_java_core::{Launch, MicrosoftAuth, LaunchOptions, MemoryOptions, LoaderOptions, JavaOptions, ScreenOptions, init_logger};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
init_logger();
// Autenticación Microsoft
let auth = MicrosoftAuth::new("00000000402b5328".to_string());
let auth_result = auth.authenticate().await?;
// Configuración del launcher - 100% compatible con la API original de TypeScript
let options = LaunchOptions {
path: "./minecraft".to_string(), // Working directory
url: None, // Custom version manifest base URL
authenticator: auth_result, // Microsoft/Mojang/AZauth profile
timeout: Some(30000), // Network timeout in milliseconds
version: "1.20.4".to_string(), // 'latest_release', 'latest_snapshot', '1.21.1'
instance: None, // Name of the instance
detached: Some(false), // Detach the Java process
intel_enabled_mac: Some(false), // Force Rosetta on Apple Silicon
download_file_multiple: Some(10), // Max parallel downloads
loader: LoaderOptions { // Mod loader configuration
enable: false, // Whether to install a mod‑loader
r#type: None, // forge, neoforge, fabric, legacyfabric, quilt
build: None, // Loader build tag (e.g. latest, 0.15.9)
path: None, // Destination folder for loader files
},
mcp: None, // Path to MCP configuration
verify: Some(true), // Verify SHA‑1 of downloaded files
ignored: vec!["saves".to_string()], // List of files to skip during verification
jvm_args: vec![], // Extra JVM arguments
game_args: vec![], // Extra Minecraft arguments
java: JavaOptions { // Java configuration
path: None, // Absolute path to Java runtime
version: Some("17".to_string()), // Force a specific Java version
r#type: "jre".to_string(), // jre or jdk
},
screen: ScreenOptions { // Screen configuration
width: None, // Width of game window
height: None, // Height of game window
fullscreen: false, // Start the game in fullscreen mode
},
memory: MemoryOptions { // Memory configuration
min: "2G".to_string(), // Minimum RAM
max: "4G".to_string(), // Maximum RAM
},
};
// Lanzar Minecraft
let mut launcher = Launch::new();
launcher.launch(options).await?;
Ok(())
}
use late_java_core::MicrosoftAuth;
let auth = MicrosoftAuth::new("00000000402b5328".to_string());
let result = auth.authenticate().await?;
use late_java_core::MojangAuth;
let auth = MojangAuth::new();
let result = auth.authenticate("usuario", "contraseña").await?;
use late_java_core::AZauthAuth;
let auth = AZauthAuth::new("https://authserver.example.com".to_string());
let result = auth.authenticate("usuario", "contraseña").await?;
use late_java_core::{StatusClient, ping_server};
// Hacer ping a un servidor
let result = ping_server("mc.hypixel.net", 25565).await?;
println!("Servidor: {}", result.server_info.description.text);
println!("Jugadores: {}/{}", result.server_info.players.online, result.server_info.players.max);
println!("Latencia: {}ms", result.latency);
use late_java_core::{Launch, LaunchEvent};
let mut launcher = Launch::new();
let mut event_receiver = launcher.subscribe();
// Escuchar eventos
while let Ok(event) = event_receiver.recv().await {
match event {
LaunchEvent::Progress { downloaded, total, element } => {
let percentage = (downloaded * 100) / total;
println!("Progreso: {}% - {:?}", percentage, element);
}
LaunchEvent::Speed(speed) => {
println!("Velocidad: {:.2} KB/s", speed / 1024.0);
}
LaunchEvent::Data(data) => {
println!("Minecraft: {}", data);
}
LaunchEvent::Close(msg) => {
println!("{}", msg);
break;
}
LaunchEvent::Error(err) => {
println!("Error: {}", err);
break;
}
_ => {}
}
}
El proyecto incluye varios ejemplos en la carpeta examples/:
basic_example.rs - Ejemplo básico de usoPara ejecutar los ejemplos:
cargo run --example basic_example
MicrosoftAuth - Autenticación Microsoft/Xbox LiveMojangAuth - Autenticación Mojang (legacy)AZauthAuth - Autenticación AZauth (servidor personalizado)Launch - Launcher principalLaunchOptions - Opciones de configuraciónLaunchEvent - Eventos del launcherVersionManifest - Manifest de versionesVersionInfo - Información de versiónStatusClient - Cliente para ping de servidoresping_server - Función de convenienciaEste proyecto está licenciado bajo la Licencia CC-BY-NC-4.0.
Las contribuciones son bienvenidas! Por favor, abre un issue o pull request.