classLoader#

class Loader(
version: str,
minecraft: str,
)#

A specific mod loader version. Subclass it to support another loader.

version#

The loader version.

Type:

str

minecraft#

The Minecraft version it targets.

Type:

str

kind#

The name it is registered under, such as neoforge.

Type:

ClassVar[str]

abstractmethod version_id(
*,
session: Session | None = None,
cache_dir: Path | None = None,
) → str#

Return the id this loader installs under in the versions directory.

Parameters:
  • session (Session | None) – The session to use. A temporary one is created if omitted.

  • cache_dir (Path | None) – The cache directory. Defaults to the per-user cache.

Returns:

The version id.

Return type:

str

abstractmethod install(
game: GameDir,
*,
java: Path | None = None,
cache_dir: Path | None = None,
session: Session | None = None,
progress: Callable[[Progress], None] | None = None,
cancel: CancelToken | None = None,
) → str#

Install into game if needed and return the version id.

Parameters:
  • game (GameDir) – The game directory.

  • java (Path | None) – The Java binary to use, if the loader needs one.

  • cache_dir (Path | None) – The cache directory. Defaults to the per-user cache.

  • session (Session | None) – The session to use. A temporary one is created if omitted.

  • progress (Callable[[Progress], None] | None) – Receives updates for each stage.

  • cancel (CancelToken | None) – Stops the install.

Returns:

The installed version id.

Return type:

str

expected_id() → str | None#

Return the version id this loader should have, without any network use.

Returns:

The version id, or None if it cannot be known in advance. That is the default, and version_id is used instead.

Return type:

str | None

is_installed(
game: GameDir,
*,
session: Session | None = None,
cache_dir: Path | None = None,
) → bool#

Return whether this loader is already installed in game.

The built-in loaders answer this from local files, with no network use.

Parameters:
  • game (GameDir) – The game directory.

  • session (Session | None) – The session to use, if the loader has to ask a service.

  • cache_dir (Path | None) – The cache directory. Defaults to the per-user cache.

Returns:

True if its version JSON exists.

Return type:

bool