mod_loader — minecraft-launcher-lib 8.0 documentation

# mod_loader

This module offers a standardized way to access the functions of various mod loaders. You should take a look at the tutorial before using this module.

Added in version 8.0.

get_mod_loader(mod_loader_id: str, /) → ModLoader

  Returns the mod loader with the given ID

  Example:

      fabric = minecraft_launcher_lib.mod_loader.get_mod_loader("fabric")

  Parameters:

    mod_loader_id (str) – the mod loader id

  Raises:

    ValueError – An invalid ID was passed

  Returns:

    The mod loader

  Return type:

    ModLoader

list_mod_loader() → list[str]

  Returns a list of all available mod loader ids

  Example:

      id_list = minecraft_launcher_lib.mod_loader.list_mod_loader()
      for current_id in id_list:
          print(current_id)

  Returns:

    A list of all ids

  Return type:

    list[str]

class ModLoader(base: ModLoaderBase)

  Bases: `object`

  This class offers a standardized way to access the functions of various mod loaders. You can obtain an instance of this class by calling `get_mod_loader()`. You should not create a new instance of this class on your own.

  Parameters:

    base (ModLoaderBase)

  get_id() → str

    Returns the ID of the mod loader

    Example:

        mod_loader = minecraft_launcher_lib.mod_loader.get_mod_loader("fabric")
        print(mod_loader.get_id())

    Return type:

      str

  get_name() → str

    Returns the name of the mod loader

    Example:

        mod_loader = minecraft_launcher_lib.mod_loader.get_mod_loader("fabric")
        print(mod_loader.get_name())

    Return type:

      str

  get_minecraft_versions(stable_only: bool) → list[str]

    Returns a list of all Minecraft versions that the mod loader supports.

    Example:

        mod_loader = minecraft_launcher_lib.mod_loader.get_mod_loader("fabric")
        for version in mod_loader.get_minecraft_versions(True):
            print(version)

    Parameters:

      stable_only (bool) – Only return stable versions and not snapshots. This parameter is not supported by every mod loader.

    Return type:

      list[str]

  is_minecraft_version_supported(minecraft_version: str) → bool

    Checks if the given minecraft version is supported by the mod loader.

    Example:

        version = "1.21"
        mod_loader = minecraft_launcher_lib.mod_loader.get_mod_loader("fabric")
        if mod_loader.is_minecraft_version_supported(version):
            print(f"{version} is supported")
        else:
            print(f"{version} is not supported")

    Parameters:

      minecraft_version (str) – A Minecraft version

    Return type:

      bool

  get_loader_versions(minecraft_version: str, stable_only: bool) → list[str]

    Returns all loader versions from newest to oldest that exists for the given Minecraft version

    Example:

        version = "1.21"
        mod_loader = minecraft_launcher_lib.mod_loader.get_mod_loader("fabric")
        loader_versions = mod_loader.get_loader_versions(version, True)
        for current_version in loader_versions:
            print(current_version)

    Parameters:

      - minecraft_version (str) – A Minecraft version.

      - stable_only (bool) – Only return stable loader versions. This parameter is not supported by every mod loader.

    Returns:

      A list of all loader versions

    Return type:

      list[str]

  get_latest_loader_version(minecraft_version: str) → str

    Returns the latest loader version for the given Minecraft version.

    Example:

        version = "1.21"
        mod_loader = minecraft_launcher_lib.mod_loader.get_mod_loader("fabric")
        latest_loader_version = mod_loader.get_latest_loader_version(version)
        print(latest_loader_version)

    Parameters:

      - minecraft_version (str) – A Minecraft version.

      - stable_only – Only return stable loader versions. This parameter is not supported by every mod loader.

    Raises:

      UnsupportedVersion – The given Minecraft version is not supported by the mod loader.

    Returns:

      The latest loader version

    Return type:

      str

  get_installed_version(minecraft_version: str, loader_version: str) → str

    This returns the version under which the mod loader will be installed. It can be used with e.g `get_minecraft_command()`.

    Example:

        vanilla_version = "1.21"
        loader_version = "0.16.14"
        mod_loader = minecraft_launcher_lib.mod_loader.get_mod_loader("fabric")
        installed_version = mod_loader.get_installed_version(vanilla_version, loader_version)
        print(installed_version)

    Parameters:

      - minecraft_version (str) – The vanilla version

      - loader_version (str) – The loader version

    Returns:

      The installed version

    Return type:

      str

  install(minecraft_version: str, minecraft_directory: str | PathLike, *, loader_version: str | None = None, callback: CallbackDict | None = None, java: str | PathLike | None = None) → str

    Installs the mod loader for the given vanilla version.

    Example:

        vanilla_version = "1.21"
        minecraft_directory = minecraft_launcher_lib.utils.get_minecraft_directory()
        mod_loader = mod_loader = minecraft_launcher_lib.mod_loader.get_mod_loader("fabric")
        mod_loader.install(vanilla_version, minecraft_directory)

    Parameters:

      - minecraft_version (str) – The vanilla Minecraft version for which to install the mod loader. If not installed, minecraft-launcher-lib will also install the vanilla version.

      - minecraft_directory (str | PathLike) – The path to your Minecraft directory

      - loader_version (str | None) – The version of the mod loader as returned by `get_loader_versions()`.If not set the latest one will be used.

      - callback (CallbackDict | None) – See Get Installation Progress

      - java (str | PathLike | None) – If set use this Java executable to execute programs during the installation.

    Raises:

      - VersionNotFound – An invalid minecraft version was passed.

      - UnsupportedVersion – The given Minecraft version is not supported by the mod loader.

    Raises:

      CalledProcessError: The execution of a program failed.

    Returns:

      The same as `get_installed_version()`.

    Return type:

      str

View the source code of this module