classModpack#

class Modpack(
format: str,
name: str,
version: str,
minecraft: str,
loader_kind: str | None,
loader_version: str | None,
entries: tuple[PackEntry, ...],
archive: Path,
override_roots: Mapping[str, str] = {},
memory_mb: int | None = None,
)#

A parsed modpack archive, independent of its format and platform.

format#

The archive format’s name, such as mrpack.

Type:

str

name#

The pack’s name.

Type:

str

version#

The pack’s version.

Type:

str

minecraft#

The Minecraft version it needs.

Type:

str

loader_kind#

The mod loader’s name as platforms use it, such as fabric for a pack that says fabric-loader, or None for a vanilla pack.

Type:

str | None

loader_version#

The mod loader’s version, or None for a vanilla pack.

Type:

str | None

entries#

The files it needs.

Type:

tuple[PackEntry, …]

archive#

The archive it was read from.

Type:

Path

override_roots#

Archive folders with extra files, keyed by common, client or server.

Type:

Mapping[str, str]

memory_mb#

The recommended memory, or None if not declared.

Type:

int | None

property loader: Loader | None#

The pack’s mod loader, or None for a vanilla pack.

Raises:

UnsupportedError – The loader is not supported.

install_game(
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 the game the pack runs on: its mod loader, or plain Minecraft.

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

  • java (Path | None) – The Java binary for loaders that need one. Found or downloaded automatically if omitted.

  • 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 version id to put in a launcher profile.

Raises:
Return type:

str

property unresolved: tuple[PackEntry, ...]#

The entries that have no download yet.

with_entries(
entries: tuple[PackEntry, ...],
) → Modpack#

Return a copy of this pack with different entries.

override_members(
side: Literal['client', 'server'] = 'client',
) → dict[str, ZipInfo]#

Return the pack’s override files without reading their contents.

Parameters:

side (Literal['client', 'server']) – The side to read.

Returns:

Each file’s archive entry, keyed by its path relative to the instance. A side-specific file replaces a common one.

Raises:

PackError – A file’s path is unsafe.

Return type:

dict[str, ZipInfo]

iter_override_files(
side: Literal['client', 'server'] = 'client',
only: Collection[str] | None = None,
) → Iterator[tuple[str, IO[bytes]]]#

Yield override files as open streams, so large files stay out of memory.

Parameters:
  • side (Literal['client', 'server']) – The side to read.

  • only (Collection[str] | None) – The relative paths to read. Defaults to every file.

Yields:

Each file’s path relative to the instance, and a stream of its contents. The stream closes when the iteration moves on.

Raises:

PackError – A file’s path is unsafe.

iter_overrides(
side: Literal['client', 'server'] = 'client',
) → Iterator[tuple[str, bytes]]#

Yield the pack’s override files with their contents.

Each file is read into memory whole. Use iter_override_files for packs with large files.

Parameters:

side (Literal['client', 'server']) – The side to read.

Yields:

Each file’s path relative to the instance, and its contents.

Raises:

PackError – A file’s path is unsafe.

extract_overrides(
dest: Path,
side: Literal['client', 'server'] = 'client',
) → list[str]#

Write the override files into dest and return their paths.

Parameters:
  • dest (Path) – The instance directory.

  • side (Literal['client', 'server']) – The side to read.

Returns:

The relative paths that were written.

Raises:

PackError – A file’s path is unsafe.

Return type:

list[str]