Skip to main content

mc_launcher_core/
lib.rs

1//! Building blocks for a Rust Minecraft launcher.
2//!
3//! `mc-launcher-core` focuses on the parts a launcher backend needs before it
4//! can hand control to Java:
5//!
6//! - resolving and installing vanilla, Fabric, Quilt, Forge, and NeoForge
7//!   profiles;
8//! - downloading client jars, libraries, assets, and native libraries;
9//! - merging inherited version metadata into a launchable [`core::version::VersionJson`];
10//! - building a [`command::builder::LaunchCommand`] that can be passed to
11//!   [`std::process::Command`];
12//! - applying compatibility metadata for older Minecraft versions on macOS
13//!   Apple Silicon.
14//!
15//! The easiest entry point is [`launcher::Launcher`]. Most applications should
16//! import [`prelude`] and keep lower-level modules for custom install or
17//! inspection workflows.
18//!
19//! # Quick Start
20//!
21//! Install Fabric, load the resulting profile, build a launch command, and run
22//! it with an offline account:
23//!
24//! ```no_run
25//! use std::process::Command;
26//!
27//! use mc_launcher_core::prelude::*;
28//!
29//! fn main() -> mc_launcher_core::Result<()> {
30//!     let minecraft_dir = std::env::current_dir()?.join(".minecraft");
31//!     let launcher = Launcher::new(minecraft_dir);
32//!
33//!     let install = launcher.install(InstallRequest {
34//!         minecraft_version: "1.20.1".to_string(),
35//!         loader: Some(LoaderSpec::Fabric {
36//!             version: LoaderVersion::LatestStable,
37//!         }),
38//!         java: JavaInstallPolicy::Auto,
39//!     })?;
40//!     let version = launcher.load_version(&install.version_id)?;
41//!
42//!     let command = launcher.build_launch_command_from_version(
43//!         &version,
44//!         LaunchOptions {
45//!             account: Account::offline("Steve"),
46//!             ..Default::default()
47//!         },
48//!     )?;
49//!
50//!     let mut child = Command::new(&command.executable)
51//!         .args(&command.args)
52//!         .current_dir(&command.working_dir)
53//!         .spawn()?;
54//!     child.wait()?;
55//!     Ok(())
56//! }
57//! ```
58//!
59//! # Module Map
60//!
61//! - [`prelude`] re-exports the stable facade types for launcher applications.
62//! - [`launcher`] contains the high-level install and command-building facade.
63//! - [`install`] plans and executes client, asset, library, loader, and native
64//!   installation work.
65//! - [`command`] turns version metadata and launch options into Java process
66//!   arguments.
67//! - [`compatibility`] adjusts metadata for known platform gaps such as legacy
68//!   macOS arm64 LWJGL support.
69//! - [`auth`] contains offline and Microsoft account helpers.
70//! - [`core`], [`io`], and [`net`] hold lower-level primitives used by the
71//!   facade.
72//!
73//! # Java Runtime
74//!
75//! The crate does not currently bundle or manage a production Java runtime for
76//! the new facade. Use [`command::builder::LaunchOptions::java_executable`] to
77//! point at the runtime your launcher selected. Older compatibility wrappers in
78//! [`runtime`] are retained for existing callers.
79//!
80//! # Error Handling
81//!
82//! New facade APIs return [`Result`], an alias over [`LauncherError`]. Errors
83//! preserve their source where possible, so callers can display simple messages
84//! or inspect variants for recovery.
85
86#![warn(rustdoc::broken_intra_doc_links)]
87
88pub mod account;
89pub mod auth;
90pub mod command;
91pub mod compatibility;
92pub mod core;
93pub mod error;
94pub mod forge;
95pub mod install;
96pub mod io;
97pub mod launcher;
98pub mod loader;
99pub mod net;
100pub mod platform;
101pub mod prelude;
102pub mod progress;
103pub mod runtime;
104pub mod types;
105pub mod utils;
106
107pub use error::{LauncherError, Result};