Expand description
ghast: a headless Minecraft Java Edition client / bot library.
This facade re-exports the bot API of ghast-client at the top level and
the lower layers as modules:
| module | crate | what |
|---|---|---|
| (root) | ghast-client | Client, Behavior, TickContext, the tick loop |
protocol | ghast-protocol | packets per version, framing, compression, encryption, NBT |
auth | ghast-auth | offline identities, SOCKS5, login crypto, Microsoft accounts |
data | ghast-data | blocks, collision shapes, items, entities |
ext (feature ext) | ghast-ext | sequential async helpers: look, dig, place, equip, containers, chat, events |
pathfinder (feature pathfinder) | ghast-pathfinder | physics-validated A* path planning and following |
viewer (feature viewer) | ghast-viewer | bot screen: live 3D view in the browser, recordings, replays |
Supported versions: 1.8.9, 1.12.2, 1.16.5, 26.1, 26.2 and 26.3. See the afk and chat examples:
cargo run -p ghast --example afk -- --host localhost --port 25565 --username Bot --version 1.8.9§Features
Every supported Minecraft version is a cargo feature (v1_8, v1_12_2, v1_16_5, v26_1,
v26_2, v26_3), all on by default; drop the ones you never connect with to cut compile
time and binary size. The version is picked at run time with GameVersion
(#[non_exhaustive]: new versions arrive in patch releases). Optional features, off by
default:
microsoft: online-mode servers (Microsoft account login, session-server join; pulls in an HTTPS client).ext:ghast::ext, sequential async helpers.pathfinder:ghast::pathfinder; withextalsoBot::goto/Bot::follow_path.viewer:ghast::viewer, the bot screen in the browser.
§Many bots
One bot: a current_thread tokio runtime. Many bots in one process: Swarm (worker
threads with one current-thread runtime each; bots are placed on the least-loaded one).
Re-exports§
pub use ghast_protocol as protocol;pub use ghast_auth as auth;pub use ghast_data as data;pub use ghast_ext as ext;pub use ghast_pathfinder as pathfinder;pub use ghast_viewer as viewer;
Modules§
- book
- Book and quill editing: what the vanilla book screen sends when the player presses Done (the pages) or signs the book (pages and title), and what it changes in the held stack.
- common
- The version-agnostic layer: what the client core receives from and sends to the server, independent of the protocol version.
- connect
- Re-exports of the connection setup types from
ghast-auth. - cooldown
- Item cooldowns (1.9+): the client’s
ItemCooldownManager(1.12.2, 1.16.5; 26.xItemCooldowns). While an item cools down a right click with it does nothing on the client after its packet (interactItem/useItemanswer PASS,interactBlock/useItemOnskip the item’s use on the block), so holding the use key with ender pearls throws one every 20 ticks, not every 4. - dialog
- Server dialogs (26.1+): the screens a server opens with
show_dialog, and the answers a vanilla client sends for them. - entity
- Entity tracking for the ghast Minecraft Java Edition client library (1.8.9, 1.12.2, 1.16.5 26.1, 26.2 and 26.3).
- fishing
- Fishing: the bot’s own fishing bobber as the vanilla client knows it, and the bite.
- hands
- The mouse buttons in the world: digging, placing, using items and hitting or using
entities, as vanilla’s key handling does it (
MinecraftClient.tick:doAttack,doUse,handleBlockBreaking;ClientPlayerInteractionManager:attackBlock,updateBlockBreakingProgress,cancelBlockBreaking,interactBlock,interactItem,attackEntity,stopUsingItem). The 1.8.9 rules were checked against recorded lab packet traces; the modern dig timing and the 26.x packets against the oracle and vanilla captures. - hud
- What the vanilla in-game HUD shows (
Interests::HUD): boss bars, the title and subtitle with their fade times, the action bar (overlay message) and the tab list’s header and footer, kept and counted down per client tick the way each version’s HUD does it; and the server’s answers to command tab-completion requests (TabCompletion, always decoded: they only arrive after acrate::TickContext::tab_complete). - inventory
- Inventory and container windows for the ghast Minecraft Java Edition client library (1.8.9, 1.12.2, 1.16.5, 26.1, 26.2 and 26.3).
- movement
- The per-tick movement packet (
ClientPlayerEntity.sendMovementPackets, 1.8 and 1.16) and the stand-in mover used untilghast-physicsis integrated. - rotation
- Rotation in whole mouse counts.
- sign
- Sign editing: the sign editor the server opens (
open_sign_entity) and the lines the client sends back (update_sign), as the vanilla sign screen does it. - swarm
- Many bots in one process:
Swarm. - teams
- The client scoreboard’s teams on every version (
Interests::TEAMS): who is on which team, each team’s prefix, suffix, colour and options, as the vanilla client keeps them from the scoreboard team packets (1.8scoreboard_team, 1.9 – 1.16.5teams, 26.xset_player_team). - throw
- The expected flight of a projectile the player throws or shoots
(
crate::TickContext::predict_throw): the launch of the item (shootFromRotationand its per-version forms, without the random spread) and then the projectile’s own ticks as the server runs them, both from the version’s oracle-proven physics (ghast_physics::<version>::{launch, projectile}), until the first block hit. - version
- Per-version glue between the generated packets of
ghast-protocoland the common layer. - world
- Chunk storage for the ghast Minecraft Java Edition client library.
Structs§
- Block
Hit - A block the crosshair is on.
- Block
Pos - A block position.
x/zmust fit 26 signed bits,y12 signed bits to be encodable. - BotContext
- What a bot gets from the swarm when it starts.
- BotHandle
- A bot in a
Swarm: stop it, wait for its result. Dropping the handle does not stop the bot. Works with any runtime (or none, seejoin_blocking), also after the swarm is gone. - Buttons
- Mouse buttons held in the world (kept until changed; released by a join or respawn).
- Chat
Message - A chat message from the server. The text stays raw JSON until asked for.
- Click
Ticket - A click that was sent: match it with
TickEvents::inventory’sclickson a later tick (window id and action number, as the server’s confirm carries them). - Client
- A configured client: where to connect, which version, which account, and how.
- Client
Settings - Client settings (
settingspacket), sent right after join game like vanilla. - Controls
- Movement keys held for the next movement step (the keyboard state in vanilla).
- Health
- Health, food and saturation (
update_health). - Idle
- A behaviour that does nothing (the player stands still).
- Interests
- A set of optional packet groups (see the associated constants).
- Pose
- The player’s pose: feet position, look, motion and movement flags.
- Profile
Keys - A profile key pair: what the Minecraft services issue for signed chat (valid for about two
days; vanilla fetches a new one once
ProfileKeys::due_refresh). - RawInbound
- A clientbound play packet copied for the behaviour (
Behavior::raw_packets). - Shutdown
Report - What
Swarm::shutdowndid. - Swarm
- Many bots in one process, on one or a few worker threads.
- Swarm
Builder - Builder of a
Swarm(Swarm::builder). - Teleport
Event - A server teleport / correction (
position) with the poses around it. - Tick
Context - The behaviour’s view of the client during one tick.
- Tick
Events - What happened since the behaviour’s previous tick.
- Tick
View - A read-only view after the movement step (
Behavior::after_tick). - Vec3
- A position or direction in world space.
- Vehicle
- The vehicle the player rides (
crate::TickContext::vehicle). - World
Time - The world’s time (
update_time), counted on between the server’s updates like the vanilla client does (the server sends one a second).
Enums§
- Account
- The account a client logs in with.
- BotError
- Why a bot has no result.
- Button
- A mouse button (
crate::TickContext::press_preview). - Click
Refused - Why
TickContext::click(or opening / closing a window) sent nothing. - Client
Error - A session failed.
- Face
- A block face, as in the dig / place packets.
- Force
Step Position - Grim compatibility (not vanilla): when to send the position on a tick whose move stayed
under vanilla’s 0.03-block resend threshold (every version; on 26.x also bounce landings on
slime and beds). See
crates/ghast-physics/GRIM_NOTES.md. - Game
Mode - Game mode.
- Game
Version - A protocol version the client supports, chosen at run time.
- Press
Outcome - What a press of a button would act on in this tick’s key handling
(
crate::TickContext::press_preview). - Session
End - How a session that reached the play state ended without an error.
Constants§
- TICK
- Length of one client tick.