Skip to main content

ghast/
lib.rs

1//! ghast: a headless Minecraft Java Edition client / bot library.
2//!
3//! This facade re-exports the bot API of [`ghast-client`](ghast_client) at the top level and
4//! the lower layers as modules:
5//!
6//! | module | crate | what |
7//! |---|---|---|
8//! | (root) | `ghast-client` | [`Client`], [`Behavior`], [`TickContext`], the tick loop |
9//! | [`protocol`] | `ghast-protocol` | packets per version, framing, compression, encryption, NBT |
10//! | [`auth`] | `ghast-auth` | offline identities, SOCKS5, login crypto, Microsoft accounts |
11//! | [`data`] | `ghast-data` | blocks, collision shapes, items, entities |
12//! | `ext` (feature `ext`) | `ghast-ext` | sequential async helpers: look, dig, place, equip, containers, chat, events |
13//! | `pathfinder` (feature `pathfinder`) | `ghast-pathfinder` | physics-validated A* path planning and following |
14//! | `viewer` (feature `viewer`) | `ghast-viewer` | bot screen: live 3D view in the browser, recordings, replays |
15//!
16//! Supported versions: 1.8.9, 1.12.2, 1.16.5, 26.1, 26.2 and 26.3. See the `afk` and `chat` examples:
17//!
18//! ```text
19//! cargo run -p ghast --example afk -- --host localhost --port 25565 --username Bot --version 1.8.9
20//! ```
21//!
22//! ## Features
23//!
24//! Every supported Minecraft version is a cargo feature (`v1_8`, `v1_12_2`, `v1_16_5`, `v26_1`,
25//! `v26_2`, `v26_3`), all on by default; drop the ones you never connect with to cut compile
26//! time and binary size. The version is picked at run time with [`GameVersion`]
27//! (`#[non_exhaustive]`: new versions arrive in patch releases). Optional features, off by
28//! default:
29//!
30//! - `microsoft`: online-mode servers (Microsoft account login, session-server join; pulls in an
31//!   HTTPS client).
32//! - `ext`: `ghast::ext`, sequential async helpers.
33//! - `pathfinder`: `ghast::pathfinder`; with `ext` also `Bot::goto` / `Bot::follow_path`.
34//! - `viewer`: `ghast::viewer`, the bot screen in the browser.
35//!
36//! ## Many bots
37//!
38//! One bot: a `current_thread` tokio runtime. Many bots in one process: [`Swarm`] (worker
39//! threads with one current-thread runtime each; bots are placed on the least-loaded one).
40
41#![forbid(unsafe_code)]
42#![warn(missing_docs, unnameable_types)]
43
44pub use ghast_client::*;
45
46/// The network protocol (`ghast-protocol`).
47pub use ghast_protocol as protocol;
48
49/// Connection setup and authentication (`ghast-auth`).
50pub use ghast_auth as auth;
51
52/// Static game data (`ghast-data`).
53pub use ghast_data as data;
54
55/// Sequential async helpers on the tick model (`ghast-ext`, feature `ext`). With the
56/// `pathfinder` feature too, `Bot::goto` walks planned paths.
57#[cfg(feature = "ext")]
58pub use ghast_ext as ext;
59
60/// Physics-validated path planning and following (`ghast-pathfinder`, feature `pathfinder`).
61#[cfg(feature = "pathfinder")]
62pub use ghast_pathfinder as pathfinder;
63
64/// The bot screen: a live 3D view of the bot's world in the browser, with recordings and
65/// replays (`ghast-viewer`, feature `viewer`). Textures come from Mojang's client jar, fetched
66/// at run time.
67#[cfg(feature = "viewer")]
68pub use ghast_viewer as viewer;