CmlLib.Core 3.1.1

.NET 5.0 .NET Core 3.1 .NET Framework 4.6.2
There is a newer version of this package available.
See the version list below for details.
NuGet\Install-Package CmlLib.Core -Version 3.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
dotnet add package CmlLib.Core --version 3.1.1
<PackageReference Include="CmlLib.Core" Version="3.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CmlLib.Core --version 3.1.1
#r "nuget: CmlLib.Core, 3.1.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install CmlLib.Core as a Cake Addin
#addin nuget:?package=CmlLib.Core&version=3.1.1

// Install CmlLib.Core as a Cake Tool
#tool nuget:?package=CmlLib.Core&version=3.1.1

CmlLib.Core

Minecraft Launcher Library

<img src='https://raw.githubusercontent.com/CmlLib/CmlLib.Core/master/logo.png' width=150>

This library is minecraft launcher library for .NET 5.0 / .NET Core 3.1 / .NET Framework 4.6.2
Support all version, with Forge

한국어 README
한국어 문서는 최신 버전이 아닙니다. 빠른 시일 내에 업데이트하겠습니다.
궁금하신게 있다면 아래 디스코드 서버 접속해서 한국어 문의하기 채널에서 물어봐주세요.

Contact

Discord

Version

Current version: 3.1.1

Functions

  • Online or Offline login
  • Download the game files from the Mojang file server
  • Launch any version (tested up to 1.16.2)
  • Launch Forge, Optifine or any other custom version
  • Download the Minecraft java runtime from the Mojang file server
  • Install Forge
  • Launch with options (direct server connecting, screen resolution)
  • Supports cross-platform (windows, ubuntu, mac, only on .NET Core)
  • Microsoft Xbox Live Login

How to 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;

How to Use

Official documentation: wiki

Sample Code

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(session.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

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

var launcher = new CMLauncher(path);
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);
};

foreach (var item in launcher.GetAllVersions())
{
    Console.WriteLine(item.Name); // list version names
}

// more options : https://github.com/AlphaBs/CmlLib.Core/wiki/MLaunchOption
var launchOption = new MLaunchOption
{
    MaximumRamMb = 1024,
    Session = session, // Login session. ex: Session = MSession.GetOfflineSession("hello")

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

// launch vanila
var process = launcher.CreateProcess("1.15.2", launchOption);

// launch forge (already installed, using this if you want to launch forge or optifine)
// var process = launcher.CreateProcess("1.16.2-forge-33.0.5", launchOption);

// launch forge (install forge if not installed, not stable, not recommended)
// var process = launcher.CreateProcess("1.16.2", "33.0.5", launchOption);

process.Start();

More information

Go to wiki

What is different between CmlLib.Core and CmlLib?

CmlLib.Core is developed using .NET Core and supports cross platform, but CmlLib doesn't support it, and is deprecated.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp3.1
.NET Framework net462 net463 net47 net471 net472 net48
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on CmlLib.Core:

Package Downloads
CmlLib.Core.Auth.Microsoft

Minecraft login with Microsoft Xbox Live account

SunCore.Ultralight.MCLauncher

SunCore.Ultralight.MCLauncher is a library for Minecraft Launchers that uses CmlLib.Core handles hard-code process with a single Launching function.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.3.5 2,450 12/20/2021
3.3.4 266 12/13/2021
3.3.3 759 10/4/2021
3.3.2 320 9/5/2021
3.3.1 627 6/22/2021
3.3.0 290 6/14/2021
3.2.0 249 6/2/2021
3.2.0-pre3 176 5/25/2021
3.2.0-pre1 176 4/8/2021
3.1.1 537 2/11/2021
3.1.0 321 12/27/2020
3.0.0 447 8/25/2020
3.0.0-alpha3 250 8/24/2020
3.0.0-alpha 314 7/3/2020
2.0.2 408 5/31/2020
2.0.1 340 5/31/2020
2.0.0 411 5/17/2020
0.2.0 400 4/13/2020
0.1.0 375 4/6/2020