Examples Documentation

Complete guide to all examples in the examples/ directory.

Overview

Example
Loader
Features
Complexity

Vanilla

Basic launch

⭐ Beginner

Fabric

Basic launch

⭐ Beginner

Quilt

Basic launch

⭐ Beginner

NeoForge

Basic launch

⭐ Beginner

Forge

Basic launch

⭐⭐ Intermediate

Forge Legacy

Basic launch

⭐⭐ Intermediate

OptiFine

Basic launch

⭐⭐ Intermediate

LightyUpdater

Custom server

⭐⭐ Intermediate

Vanilla

Events + Instance Control

⭐⭐⭐ Advanced

Running Examples

Basic Command

cargo run --example <example_name> --features <required_features>

With Tracing (Debug Output)

cargo run --example <example_name> --features <required_features>,tracing

Common Feature Combinations


vanilla.rs

Purpose: Basic Vanilla Minecraft launcher with custom JVM options and game arguments

Loader: Vanilla Features Required: vanilla

What It Demonstrates

  • ✅ AppState initialization

  • ✅ Offline authentication

  • ✅ VersionBuilder creation

  • ✅ Custom JVM options (memory, etc.)

  • ✅ Custom game arguments (resolution)

  • ✅ Downloader configuration

  • ✅ Basic launch flow

Code Walkthrough

Key Concepts

  1. AppState: Manages project directories (data, config, cache)

  2. DownloaderConfig: Configures parallel downloads and retries

  3. JVM Options: Memory allocation, garbage collection

  4. Game Arguments: Window resolution, fullscreen, etc.

Run It


fabric.rs

Purpose: Fabric mod loader launcher

Loader: Fabric Features Required: fabric

What It Demonstrates

  • ✅ Fabric loader integration

  • ✅ Loader version specification

  • ✅ Metadata merging (Vanilla + Fabric)

Code Highlights

How It Works

  1. Fetches Vanilla 1.21.1 metadata

  2. Fetches Fabric 0.17.2 loader data

  3. Merges metadata (adds Fabric libraries, updates main class)

  4. Launches with merged metadata

Run It


quilt.rs

Purpose: Quilt mod loader launcher

Loader: Quilt Features Required: quilt

What It Demonstrates

  • ✅ Quilt loader integration

  • ✅ Alternative to Fabric

Code Highlights

Run It


neoforge.rs

Purpose: NeoForge mod loader launcher

Loader: NeoForge Features Required: neoforge

What It Demonstrates

  • ✅ NeoForge loader (modern Forge fork)

  • ✅ Latest Minecraft versions

Code Highlights

Run It


forge.rs

Purpose: Forge mod loader launcher

Loader: Forge Features Required: forge

What It Demonstrates

  • ✅ Forge loader (modern versions)

  • ✅ Complex metadata merging

Code Highlights

Run It


forge_legacy.rs

Purpose: Legacy Forge launcher (1.7.10 - 1.12.2)

Loader: Forge Legacy Features Required: forge_legacy

What It Demonstrates

  • ✅ Legacy Forge versions

  • ✅ Older Minecraft versions

  • ✅ Different metadata format

Code Highlights

Run It


optifine.rs

Purpose: OptiFine launcher

Loader: OptiFine Features Required: optifine

What It Demonstrates

  • ✅ OptiFine integration

  • ✅ Performance optimization mod

Code Highlights

Run It


lighty_updater.rs

Purpose: Custom modpack server launcher

Loader: LightyUpdater Features Required: lighty_updater

What It Demonstrates

  • ✅ Custom server integration

  • ✅ LightyVersionBuilder

  • ✅ Server-managed modpacks

  • ✅ Automatic mod updates

Code Highlights

How It Works

  1. GET {server_url}/version

  2. Fetches Vanilla + Loader metadata

  3. Adds server mods to metadata

  4. Downloads and installs mods

  5. Launches game

Server Setup

See LightyUpdater Repositoryarrow-up-right for server implementation.

Run It


with_events.rs

Purpose: Complete demonstration of event system and instance management

Loader: Vanilla Features Required: vanilla, events

What It Demonstrates

  • ✅ Event bus creation and subscription

  • ✅ All event types (Auth, Java, Launch, Loader, Core, Instance)

  • ✅ Real-time progress tracking

  • ✅ Console output streaming

  • ✅ Instance lifecycle management

  • ✅ Instance size calculation

  • ✅ PID tracking

  • ✅ Instance control (close, delete)

Code Walkthrough

Event Types Demonstrated

1. Authentication Events

2. Java Events

3. Launch Events

4. Loader Events

5. Core Events

6. Instance Events

Instance Control Operations

Run It

Expected Output:


Common Patterns

Pattern 1: Basic Launch

Pattern 2: With Custom Options

Pattern 3: With Events

Pattern 4: Instance Management

Troubleshooting

Error: "Failed to fetch metadata"

Solution: Check internet connection and loader availability

Error: "Java not found"

Solution: Ensure Java distribution is supported for the Minecraft version

Error: "Instance is running"

Solution: Close instance before deleting:

Last updated