ltk_modpkg
A Rust library for reading, writing, and packing .modpkg archives, the binary mod distribution format for League of Legends mods in the League Mod Toolkit.
Overview
A .modpkg file is a binary container that stores mod content organized by layers and WAD targets, with per-chunk zstd compression, xxhash checksums, and embedded metadata (name, version, authors, license, thumbnail, etc.).
This crate provides:
- Reading: mount a modpkg from any
Read + Seeksource and access chunks by path hash - Writing: build a modpkg from scratch using
ModpkgBuilder - Extraction: extract modpkg contents back to disk
- Metadata: read/write msgpack-encoded mod metadata
Packing a mod project directory into a modpkg lives in the ltk_mod_project
crate (its modpkg cargo feature), whose ModpkgFormat backend drives
ModpkgBuilder from here.
Usage
Reading a modpkg
use Modpkg;
use File;
let file = open?;
let mut modpkg = mount_from_reader?;
// Read metadata
let metadata = modpkg.load_metadata?;
println!;
// List WADs
for wad_name in modpkg.wads.values
Packing a mod project
Project packing lives in ltk_mod_project behind its modpkg feature. The
format-neutral ProjectPacker scans the project; ModpkgFormat encodes it:
use ModpkgFormat;
use ProjectPacker;
// Loads mod.config.json/toml automatically from the project directory
let packer = from_dir?;
let file = create?;
packer.pack?;
Building a modpkg programmatically
use ;
use ModpkgCompression;
let builder = default
.with_layer
.with_chunk;
let mut output = create?;
builder.build_to_writer?;
Project structure
The expected mod project layout (used by ltk_mod_project's ProjectPacker):
my-mod/
├── mod.config.json # or mod.config.toml
├── README.md # optional, embedded in modpkg
├── thumbnail.webp # optional, embedded in modpkg
├── content/
│ ├── base/ # base layer (priority 0)
│ │ ├── Graves.wad.client/ # WAD target directory
│ │ │ ├── data/
│ │ │ └── assets/
│ │ └── Map11.wad.client/
│ │ └── data/
│ └── high-res/ # additional layer
│ └── Graves.wad.client/
│ └── assets/
└── build/ # output directory
License
Apache-2.0