ghast v0.5.6

A headless Minecraft client that moves exactly like the real one.

ghast is a Rust library for writing Minecraft: Java Edition bots. One API covers 1.8.9 to 26.3, and its player physics match the vanilla client bit for bit.

cargo add ghast
Read the guide

Version 0.5.6, 288 downloads on crates.io. MIT or Apache 2.0.

Checked against the real client, bit by bit

An oracle runs the vanilla client’s own movement code headless and records what it does on every tick. ghast gets the same inputs. Positions, velocities, flags and packets must then be equal by their bits, not close.

tick 000000 50 ms a tick
vanillaghastequal
y40500000000000004050000000000000=
vybfb4133333333334bfb4133333333334=
on_ground11=
An illustration of what is compared: a jump’s height and vertical speed as 64-bit floats, one row of bits per game tick. The measured runs are in the table.
Compared with vanillaResultSize of the run
Player physics on 1.8.9, 1.12.2 and 1.16.50 diffs17.72 million ticks of randomized input
Player physics on 26.10 diffs12.20 million ticks, including elytra, riptide, boats and minecarts
Player physics on 26.20 diffs16.20 million ticks, adding slime, beds and the bounce attributes
Player physics on 26.30 diffs17.2 million ticks in 182,000 randomized cases, adding pistons
Window clicks against vanilla’s own prediction0 diffsAbout 154,000 random clicks per version up to 1.16.5; 237,292 each on 26.1 and 26.2; 493,900 on 26.3
Protocol codecsbyte-exactEvery packet of every version, both directions, against node-minecraft-protocol
Sessions on Paper with the Grim anticheat0 flags30 minutes of mixed walking, sprinting, digging, placing and clicking per version

Grim and vanilla disagree in a few corner cases where the real client sends the same packets; those are documented one by one. How the numbers are measured

A bot is a type with a tick

The game advances in steps of 50 ms. ghast calls your behaviour once per step, with the world as the client sees it and the controls a player would have.

interests
Name what you want to hear about. Packets nobody asked for are dropped before they are decoded.
tick
Read the state, set the inputs. Movement comes out of the same physics the vanilla client runs.
GameVersion
Change this one value and the same bot joins a server of another version.

Build this bot step by step

use ghast::{Account, Behavior, Client, GameVersion, Interests, TickContext};

struct Afk;

impl Behavior for Afk {
    fn interests(&self) -> Interests {
        Interests::CHAT
    }

    fn tick(&mut self, ctx: &mut TickContext<'_>) {
        for m in &ctx.events().chat {
            println!("{}", m.plain());
        }
        if ctx.is_dead() {
            ctx.respawn();
        }
        if ctx.tick() % 200 == 0 {
            let p = ctx.pose().pos;
            println!("at {:.1} {:.1} {:.1}", p.x, p.y, p.z);
        }
    }
}

#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new(
        "localhost:25565".parse()?,
        GameVersion::V1_8_9,
        Account::offline("Bot")?,
    );
    client.run(&mut Afk).await?;
    Ok(())
}

Old servers and new ones, behind one API

Each version is verified against that version’s own client, and each is a cargo feature, so a bot for one server compiles only what it uses.

  1. 1.8.9 protocol 47 and 1.8 to 1.8.8
  2. 1.12.2 protocol 340 and 1.12.1
  3. 1.16.5 protocol 754 and 1.16.2 to 1.16.4
  4. 26.1 protocol 775 to 26.1.2
  5. 26.2 protocol 776
  6. 26.3 protocol 777

What differs between versions

Small enough to run by the hundred

A few megabytes a bot

An idle bot built for a single version takes 5.0 MB of memory on 1.8.9 and 6.4 MB on 26.1 (resident set, x86-64, measured 2026-11-12).

Many bots, few threads

Swarm runs any number of bots on a handful of worker threads. Bots standing in the same area can hold each identical chunk section once. Running swarms

Made for small machines

The design target is many bots on a Raspberry Pi 5: CPU first, then robustness, then memory. This website is served from one, too.

Three optional tools

ext
Write a bot as a script: look, dig, place, open a chest, wait for chat. Async helpers that still run on the tick loop.
pathfinder
A* planning with costs measured in the physics, and a follower that checks every move against it before making it.
viewer
See what the bot sees: a live 3D view of its world in a browser tab, with recordings and replays.