Skip to content

A swift Minecraft launcher made using WinUI technologies in the fast C# language that really pushes the boundary of the platform.

License

Notifications You must be signed in to change notification settings

RiversideValley/CmlLib.Core

 
 

Repository files navigation

CmlLib.Core

Minecraft Launcher Library

Nuget Badge GitHub license Codacy Badge

Discord

CmlLib.Core is a Minecraft launcher library for .NET
It supports all versions, including Forge

한국어 README

简体中文 README

Features

  • Asynchronous APIs
  • Mojang Authentication
  • Microsoft Xbox Live Login
  • Download the game files from the Mojang file server
  • Launch any version (tested up to 1.18.2)
  • Launch Forge, Optifine, FabricMC, LiteLoader or any other custom version
  • Install Java runtime
  • Install LiteLoader, FabricMC
  • Launch with options (direct server connecting, screen resolution)
  • Cross-platform (Windows, Linux, macOS)

Go to the wiki for all features

Install

Install the CmlLib.Core Nuget package

or download the DLL files in Releases and add references to them in your project.

Write this at the top of your source code:

using CmlLib.Core;
using CmlLib.Core.Auth;

Documentation

There are many features for custom launchers. Read the wiki to see all of the features.
Official documentation: wiki

Quick start

Microsoft Xbox Login

CmlLib.Core.Auth.Microsoft
Wiki

Mojang Login

Login Process

var login = new MLogin();
var response = login.TryAutoLogin();

if (!response.IsSuccess) // failed to automatically log in
{
    var email = Console.ReadLine();
    var pw = Console.ReadLine();
    response = login.Authenticate(email, pw);

    if (!response.IsSuccess)
         throw new Exception(response.Result.ToString()); // failed to log in
}

// This session variable is the result of logging in and is used in MLaunchOption, in the Launch part below.
var session = response.Session;

Offline Login

// This session variable is the result of logging in and is used in MLaunchOption, in the Launch part below.
var session = MSession.GetOfflineSession("USERNAME");

Launch

// increase connection limit to fast download
System.Net.ServicePointManager.DefaultConnectionLimit = 256;

//var path = new MinecraftPath("game_directory_path");
var path = new MinecraftPath(); // use default directory

var launcher = new CMLauncher(path);

// show launch progress to console
launcher.FileChanged += (e) =>
{
    Console.WriteLine("[{0}] {1} - {2}/{3}", e.FileKind.ToString(), e.FileName, e.ProgressedFileCount, e.TotalFileCount);
};
launcher.ProgressChanged += (s, e) =>
{
    Console.WriteLine("{0}%", e.ProgressPercentage);
};

var versions = await launcher.GetAllVersionsAsync();
foreach (var item in versions)
{
    // show all version names
    // use this version name in CreateProcessAsync method.
    Console.WriteLine(item.Name);
}

var launchOption = new MLaunchOption
{
    MaximumRamMb = 1024,
    Session = session, // replace this with login session value. ex) Session = MSession.GetOfflineSession("hello")

    //ScreenWidth = 1600,
    //ScreenHeight = 900,
    //ServerIp = "mc.hypixel.net"
};

//var process = await launcher.CreateProcessAsync("input version name here", launchOption);
var process = await launcher.CreateProcessAsync("1.15.2", launchOption); // vanilla
// var process = await launcher.CreateProcessAsync("1.12.2-forge1.12.2-14.23.5.2838", launchOption); // forge
// var process = await launcher.CreateProcessAsync("1.12.2-LiteLoader1.12.2"); // liteloader
// var process = await launcher.CreateProcessAsync("fabric-loader-0.11.3-1.16.5") // fabric-loader

process.Start();

Example

Sample Code

About

A swift Minecraft launcher made using WinUI technologies in the fast C# language that really pushes the boundary of the platform.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages

  • C# 99.4%
  • Shell 0.6%