classModpack#

class Modpack(
format: str,
name: str,
version: str,
minecraft: str,
loader_kind: str,
loader_version: str,
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.

Type:

str

loader_version#

The mod loader’s version.

Type:

str

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#

The pack’s mod loader.

Raises:

UnsupportedError – The loader is not supported.

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.

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]