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
  • RulesEvaluator
  • Examples
  • Built-in Implementation
  • RulesEvaluatorContext
Edit on GitHub
  1. CmlLib.Core
  2. More APIs

Rules

RulesEvaluator

The IRulesEvaluator interface evaluates the given rules to determine whether a file or parameter should be used. Some parameters or files are only applicable in specific OS versions or when certain features are enabled.

Examples

  • OS-specific files: lwjgl-windows is only enabled on Windows.

  • Feature-specific parameters: The --demo parameter is only used if the is_demo_user feature is enabled.

Game versions provide a rules property to specify in which environments particular features should be enabled.

Built-in Implementation

The built-in implementation of IRulesEvaluator, named RulesEvaluator, behaves identically to the Mojang Launcher’s implementation. In most cases, this implementation is sufficient.

If you need custom behavior, you can implement your own IRulesEvaluator. You can set your IRulesEvaluator in MinecraftLauncherParameters.

RulesEvaluatorContext

RulesEvaluatorContext represents the current environment information for evaluating the given rules. This includes the OS type, version, architecture, and list of enabled features currently running.

The code below creates a RulesEvaluatorContext that represents the current environment.

var context = new RulesEvaluatorContext(LauncherOSRule.Current, []);

If you want to simulate running in a different environment, you can initialize the RulesEvaluatorContext by yourself.

var context = new RulesEvaluatorContext(new LauncherOSRule("windows", "64", "10.0"), []);

You can set the value of RulesContext for the launcher.

var launcher = new MinecraftLauncher();
launcher.RulesContext = new RulesEvaluatorContext(new LauncherOSRule("windows", "64", "10.0"), []);

PreviousMinecraftLauncherParametersNextFileExtractor

Last updated 2 months ago

🚀