CmlLib
English (v4)
English (v4)
  • 🧊CmlLib Projects
  • 🚀CmlLib.Core
    • Home
    • Getting Started
      • Minecraft Launcher
      • Minecraft Path
      • Versions
      • Launch Options
      • Event Handling
    • Login and Sessions
      • Microsoft Xbox Account
      • Offline Account
    • More APIs
      • MinecraftLauncherParameters
      • Rules
      • FileExtractor
      • GameInstaller
      • Java
    • Mod Loader Installers
      • Forge Installer
      • Fabric Installer
      • Quilt Installer
      • LiteLoader Installer
    • Utilities
      • Minecraft Changelogs
    • Resources
      • FAQ
      • Known Issues
      • Sample Launcher
      • License
  • 🔓Auth.Microsoft
    • Home
    • CmlLib.Core.Auth.Microsoft
      • JELoginHandler
      • JELoginHandlerBuilder
      • JEAuthenticator
      • Authentication with MSAL
    • XboxAuthNet.Game
      • OAuth
      • XboxAuth
      • XboxAuthException
      • AccountManager
      • Accounts
    • XboxAuthNet.Game.Msal
      • ClientID
      • MsalClientHelper
      • OAuth
    • CmlLib.Core.Bedrock.Auth
    • Resources
  • 🌐MojangAPI
    • Home
    • Mojang API
    • SecurityQuestion
  • ⚒️Installer.Forge
    • Home
    • Supported Versions
    • Getting Started
    • MForge
    • ForgeVersionLoader
Powered by GitBook
On this page
  • Example
  • BasicGameInstaller
  • ParallelGameInstaller
Edit on GitHub
  1. CmlLib.Core
  2. More APIs

GameInstaller

Download game files

IGameInstaller checks for the existence and integrity of the file and downloads it if necessary.

The GameInstaller fires events that indicate the progress of the installation. See Event Handling

Example

var installer = ParallelGameInstaller.CreateAsCoreCount(new HttpClient());
var file = new GameFile("name")
{
    Path = "absolute path of the file",
    Hash = "SHA1 checksum, in hex string",
    Size = 1024, // file size
    Url = "URL to download the file",
};
await installer.Install([file], fileProgress, byteProgress, CancellationToken.None);

BasicGameInstaller

Single-threaded installer

var installer = new BasicGameInstaller(new HttpClient());

ParallelGameInstaller

Multi-threaded installer. CreateAsCoreCount method initializes a new ParallelGameInstaller with the number of cores of the current PC.

var installer = ParallelGameInstaller.CreateAsCoreCount(new HttpClient());

You can specify the maximum number of concurrences for each task:

var installer = new ParallelGameInstaller(
    maxChecker: 4,
    maxDownloader: 8,
    boundedCapacity: 2048, // download queue size
    new HttpClient());
PreviousFileExtractorNextJava

Last updated 10 months ago

🚀