Host calls

Resource packs

Hosting a pack on the server's own pack host, and sending packs to players.

Generated by tools/gen_api_docs.py; do not edit by hand. See host calls for how a call is made and how values are encoded. Each example shows the shape of a Wasm request with its required fields; the values in it are illustrative.

CallWhat it does
push_packOffers a resource pack to one player, on top of any they already hold.
host_packHosts a resource pack on the server's own pack host and answers its URL and SHA-1, for push_pack.
pop_packTakes a pack back off.

push_pack

fn push_pack(player: PlayerId, id: u128, url: &str, hash: &str, required: bool) -> bool

Offers a resource pack to one player, on top of any they already hold.

Packs stack. Pushing a second does not replace the first: the client keeps both and the newer one wins for any file they share. pop_pack is how one comes off.

Wasm request

FieldTypeRequired
playerplayer id (integer)yes
id32 hex digits, dashes allowedyes
urlstringyes
hashstringyes
requiredtrue or falseno

Router notes: The id is a hex string, for player_uuid's reason: a u128 does not survive a JSON number, which is a double. Sixteen bytes written as thirty-two hex digits is what every guest can print and parse without a bignum.

Reply: {"ok": ...} holding the Rust return value bool, encoded as in conventions.

{"call": "push_pack", "player": 7, "id": "spawn", "url": "https://example.com/", "hash": "<sha1 hex>"}

host_pack

fn host_pack(plugin: &str, name: &str, source: crate::pack::PackSource<'_>) -> Result<crate::pack::HostedPack, String>

Hosts a resource pack on the server's own pack host and answers its URL and SHA-1, for push_pack. name is the pack's name in the URL: letters, digits, _ and -, a .zip on the end or not. Refused when rustmc.yml leaves pack-host off, for a name or path that does not read, and for a pack over pack-host.max-pack-mib. See pack.

Wasm request

FieldTypeRequired
namestringyes
filestringno
base64stringno
directorystringno

Shape: Exactly one source: base64 (the zip's bytes), file (a zip in the plugin's folder) or directory: true (the plugin's folder itself).

Shape and limits, as the router words its errors: "base64 should be a string"; "base64 is not base64: …"; "give exactly one of base64, file or directory: true".

Router notes: The plugin is the manifest's name, as for store: a guest hosts only under its own. plugin is never sent by a Wasm guest: the server fills it in from the manifest name.

Reply: {"ok": ...} holding the Rust return value Result<crate::pack::HostedPack, String>, encoded as in conventions; objects in it carry url, sha1. An Err arrives as {"error": "..."}.

{"call": "host_pack", "name": "Steve"}

pop_pack

fn pop_pack(player: PlayerId, id: Option<u128>) -> bool

Takes a pack back off. None removes every pack, not the most recent.

Wasm request

FieldTypeRequired
playerplayer id (integer)yes
id32 hex digits, dashes allowedno

Router notes: null removes every pack rather than the most recent, which is the host's own rule -- so an absent id has to stay absent rather than defaulting to something.

Reply: {"ok": ...} holding the Rust return value bool, encoded as in conventions.

{"call": "pop_pack", "player": 7}

From docs/api/reference/host-calls/packs.md in the RustMC repository at bbd81209ad.