11 releases (3 stable)

1.0.2 Dec 28, 2024
1.0.1 Dec 26, 2024
0.4.1 Dec 24, 2024
0.3.2 Dec 18, 2024
0.1.1 Nov 25, 2024

#46 in Games

Download history 208/week @ 2024-11-20 89/week @ 2024-11-27 131/week @ 2024-12-04 219/week @ 2024-12-11 394/week @ 2024-12-18 433/week @ 2024-12-25 24/week @ 2025-01-01 43/week @ 2025-01-08

1,012 downloads per month

MIT/Apache

105KB
2.5K SLoC

Lyceris

An open source Minecraft launcher library written in Rust.

Crates.io MIT/Apache 2.0 Crates.io

About The Project

Product Screenshot

Lyceris is written with functional programming paradigm to achieve simplicity. It supports Microsoft authentication, loaders like Fabric, Quilt (more will be implemented soon), multi-threaded control system and download parallelism. It also automatically downloads necessary Java version. Library name comes from a character from Sword Art Online anime.

Supported Mod Loaders

  • Forge (Above version 1.12.2)
  • Fabric
  • Quilt

Versions below 1.12.2 Forge is not supported and won't be supported in the future.

Getting Started

cargo add lyceris

Usage

This is the example implementation with using Quilt mod loader in version 1.20. Don't forget to change the game directory path!

use std::env;

use lyceris::minecraft::{
    config::ConfigBuilder, emitter::Emitter, install::install, launch::launch,
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Emitter uses `EventEmitter` inside of it
    // and it uses tokio::Mutex for locking.
    // That causes emitter methods to be async.
    let emitter = Emitter::default();

    // Single download progress event send when
    // a file is being downloaded.
    emitter
        .on(
            "single_download_progress",
            |(path, current, total): (String, u64, u64)| {
                println!("Downloading {} - {}/{}", path, current, total);
            },
        )
        .await;

    // Multiple download progress event send when
    // multiple files are being downloaded.
    // Java, libraries and assets are downloaded in parallel and
    // this event is triggered for each file.
    emitter
        .on(
            "multiple_download_progress",
            |(current, total): (u64, u64)| {
                println!("Downloading {}/{}", current, total);
            },
        )
        .await;

    // Console event send when a line is printed to the console.
    // It uses a seperated tokio thread to handle this operation.
    emitter
        .on("console", |line: String| {
            println!("Line: {}", line);
        })
        .await;

    let current_dir = env::current_dir()?;
    let config = ConfigBuilder::new(
        current_dir.join("game"),
        "1.21.4",
        lyceris::auth::AuthMethod::Offline {
            username: "Lyceris",
            // If none given, it will be generated.
            uuid: None,
        },
    )
    .build();

    // Install method also checks for broken files
    // and downloads them again if they are broken.
    install(&config, Some(&emitter)).await?;

    // This method never downloads any file and just runs the game.
    launch(&config, Some(&emitter)).await?.wait().await?;

    Ok(())
}

Roadmap

  • Download resumption

See the open issues for a full list of proposed features (and known issues).

License

Distributed under the MIT License. See MIT License for more information.

Dependencies

~18–33MB
~496K SLoC