ghast v0.5.6

Getting started

Installation

After this page you have ghast in a Cargo project with the features you need, you know how to build it for a single Minecraft version, and you can run the examples that ship with the repository.

Requirements

ghast needs Rust 1.89 or newer (rust-version = "1.89", edition 2024) on the stable toolchain. Building it needs no Java or Node: the generated code is committed.

The bot API is async and runs on tokio. ghast does not start a runtime for you, so add tokio to your own project as well:

cargo add ghast
cargo add tokio --features rt,macros,signal

rt and macros give you #[tokio::main]; signal is for stopping a bot with Ctrl-C, as the examples do. One bot runs best on a current_thread runtime. A multi-thread runtime gains nothing for a single bot and costs CPU in thread wake-ups; for many bots in one process see Swarms.

Feature flags

The ghast facade crate re-exports the bot API of ghast-client at the top level and the lower layers as ghast::protocol, ghast::auth and ghast::data. Its features:

FeatureDefaultWhat it adds
v1_8, v1_12_2, v1_16_5, v26_1, v26_2, v26_3onone feature per game version
libdeflateonpacket compression with libdeflate (C, faster); without it pure Rust (flate2 + zlib-rs)
display-namesonEnglish display names of blocks, items and entities in ghast::data; off saves about 120 to 200 KB
microsoftoffonline-mode servers (Microsoft accounts); pulls in an HTTPS client
extoffghast::ext, sequential async helpers: look, dig, place, equip, containers, chat, events
pathfinderoffghast::pathfinder, physics-checked path planning and following; with ext, also Bot::goto
vieweroffghast::viewer, a live 3D view of the bot's world in the browser, with recordings and replays

Registry names (minecraft:stone) are always there; display-names only adds the English names. The sub-versions 1.12.1, 1.16.2 and 1.16.3 come with the feature of their row (v1_12_2 or v1_16_5).

Turn on optional features the usual way:

cargo add ghast --features ext,pathfinder

The viewer feature downloads the vanilla client jar from Mojang's servers at run time to build its textures; nothing from Mojang is shipped in the crate. See Bot screen (viewer).

Building for one version

Every version is on by default. Each version feature builds alone, so a bot that only ever joins one server version can drop the rest, which cuts compile time and binary size:

[dependencies]
ghast = { version = "0.5", default-features = false, features = ["v1_8", "libdeflate"] }

With default-features = false you also lose display-names; add it back if you read English names from ghast::data. The same build from the command line:

cargo add ghast --no-default-features --features v1_8,libdeflate

A GameVersion whose feature is off still exists in the enum. Running a client with it returns ClientError::VersionNotEnabled instead of failing to compile, and GameVersion::enabled() tells you in advance.

The root README measured the afk example, stripped, with the release profile below (2026-11-11): 5.3 MB with every version and 1.9 MB with 1.8.9 only. On 2026-11-13 (0.4.2, with two modern versions): 7.9 MB with every version, 4.2 MB with 26.1 only. Each modern version is its own compiled copy of the modern client, so every 26.x feature you keep adds to the size.

A release profile

A library cannot set your build profile. The README's numbers use this one:

[profile.release]
opt-level = 3
lto = "fat"
codegen-units = 1
strip = true

If you run many bots as separate processes, the README also suggests building without PIE (RUSTFLAGS="-C relocation-model=static" with an explicit --target), so that the generated data tables are shared between processes instead of copied into each one.

Using a lower-level crate on its own

All crates are published separately with the same version number, and dependencies point one way: the protocol crate knows nothing about the layers above it. If you only need packets, framing, compression and encryption, depend on ghast-protocol alone:

cargo add ghast-protocol --no-default-features --features v1_8,tokio

Its features are the version features again (v1_8, v1_12_2, v1_16_5, v26_1, v26_2, v26_3), tokio for the async framed reader and writer, libdeflate, and chat-json for parsing chat components. A small check of its protocol table:

fn main() {
    for v in ghast_protocol::versions::enabled() {
        println!("protocol {} ({}): {:?}", v.protocol, v.feature, v.game_versions);
    }
    let row = ghast_protocol::versions::by_game_version("1.8.9").expect("in the table");
    println!("1.8.9 is protocol {}", row.protocol);
}

The other layers work the same way: ghast-physics is pure movement code with no I/O and no clock, ghast-world stores chunks, ghast-data holds blocks, items and collision shapes. Their APIs are on docs.rs, for example /docs/ghast-protocol and /docs/ghast-physics. The layering is described in Architecture.

Running the bundled examples

The examples live in crates/ghast/examples/ of the repository. Clone it and run one against a server, for example an offline-mode server on your own machine:

git clone https://github.com/Crefax/Ghast
cd Ghast
cargo run -p ghast --release --example afk -- \
    --host localhost --port 25565 --username AfkBot --version 1.8.9

--version takes 1.8.9, 1.12.2, 1.16.5, 26.1, 26.2 or 26.3. Other options shared by the examples: --proxy socks5h://user:pass@host:1080, --policy except-local|require|prefer|direct, --minutes N, --reconnect and -v. The chat example prints the server's chat and sends every line you type:

cargo run -p ghast --example chat -- --host localhost --port 25565 --username ChatBot --version 26.3

Some examples need optional features: goto needs --features ext,pathfinder, and ride, hud and fishing need --features ext. Next: First bot.