> For the complete documentation index, see [llms.txt](https://docs.aethercube.fr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aethercube.fr/developers/content-packs/packaging-and-delivery.md). Agents can also search and read this documentation through its [MCP server](https://docs.aethercube.fr/~gitbook/mcp).

# Packaging and delivery

How a pack travels from your server folder to a player's screen. You do not need this to write a pack, because the server does it all. Read it to understand the download, to debug a stuck join, or to write a client.

## The AEPK archive

The server builds each pack into one archive in the AEPK v1 format and hashes it. Everything is little-endian and uncompressed.

```
magic        "AEPK"         4 bytes
version      u16 = 1
count        u32            number of entries, 1 .. 4096
then `count` times:
  path_len   u16            1 .. 200
  path       UTF-8          relative path, '/'-separated
  data_len   u32
  data       bytes
```

Entries are sorted by path in byte order, with no duplicates. The server always writes the same bytes for the same files, so the same pack gives the same hash from one start to the next. That is what lets a client keep a pack in its cache and skip the download.

The archive is hashed with BLAKE3. The client uses the hash as the identity of the pack: its cache file name, and the check of a download.

The server builds the archive from a folder (every file below it), from a `.zip` file, or from the `content/` folder of a plugin jar. You never write an AEPK by hand.

## The content phase

A client that announces the feature `content_packs/1` in `ClientCapabilities` goes through the content phase after authentication and before `ConnectionAccepted`.

```mermaid
sequenceDiagram
    participant C as Client
    participant S as Server
    C->>S: ClientCapabilities (content_packs/1)
    Note over S: authentication and admission
    S->>C: ContentPackList
    S->>C: ContentRegistry
    loop each pack missing from the cache
        C->>S: ContentPackRequest (index)
        S->>C: ContentPackChunk ... last
    end
    C->>S: ContentPacksReady (accepted)
    S->>C: ConnectionAccepted
```

| Packet               | Id       | Direction        | Purpose                                             |
| -------------------- | -------- | ---------------- | --------------------------------------------------- |
| `ContentPackList`    | `0x000B` | server to client | The packs, in order, and whether they are required. |
| `ContentPackRequest` | `0x000C` | client to server | Send me pack `index`.                               |
| `ContentPackChunk`   | `0x000D` | server to client | A piece of that pack's archive.                     |
| `ContentPacksReady`  | `0x000E` | client to server | Done: accepted or declined.                         |
| `ContentRegistry`    | `0x000F` | server to client | Plugin items and creature types.                    |
| `ScreenEffect`       | `0x070B` | server to client | Draw a pack screen effect, or none.                 |

Rules:

* The phase always runs for a client that announces the feature, even when there is no pack and no plugin content. The list and the registry are then empty.
* The client requests packs in list order and sends the next request only after the last chunk of the previous pack arrived.
* A client that does not announce the feature skips the phase. If the server has packs and `content_packs.required` is `true`, that client is refused with `ConnectionRejected` reason `CONTENT_REQUIRED` (10).
* `ContentPacksReady.accepted = false` while `required` is set closes the connection with `DisconnectNotice` (`KICKED`) and the message "This server needs its content packs." When `required` is `false`, the player joins without the packs. The client still uses `ContentRegistry`, with fallback icons and boxes.
* During the phase the client sends `ClientKeepAlive` every 10 seconds, so a long download does not hit the idle limit.
* Any packet other than `ContentPackRequest`, `ContentPacksReady`, `ClientKeepAlive` and `DisconnectRequest` is a fatal protocol error. So is a request for an index out of range, a request while a pack is still being sent, and a third request for the same index.
* The server closes the connection with `TIMEOUT` when the phase lasts more than 10 minutes, or when 30 seconds pass without a packet from the client.

## Transfer

* The server sends each requested pack in chunks of 256 KiB. Only the last is shorter.
* It paces itself: at most 8 chunks (2 MiB) are written and not yet flushed per connection. It sends from its own pool, never from the simulation thread.
* Frames over 1 KiB are compressed by the codec, so the transfer is compressed although the archive is not.
* The client checks the size and the hash of each pack it received. On a mismatch it requests the pack once more. A second failure declines the packs.

## Client cache

* Packs are stored in `<data>/packs/<blake3 hex>.aepk`.
* A cached pack is used when its size and hash match. It is re-read and re-hashed on use. A bad file is deleted and downloaded again.
* The cache holds at most 1 GiB. Beyond that, the least recently used packs are deleted.
* A client with no cache directory, such as the headless client, still runs the phase. It downloads into memory, checks, and discards.

## Client setting

The player controls whether packs are accepted in `client.toml`:

```toml
content_packs = "accept"   # or "decline"
```

A client set to `decline` answers `ContentPacksReady` with `accepted = false`. On a server with `content_packs.required: true`, that player is kicked.

## Server settings

See [Content packs on the server](https://docs.aethercube.fr/developers/running-a-server/content-packs-settings.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.aethercube.fr/developers/content-packs/packaging-and-delivery.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
