Skip to main content

Crate ghast

Crate ghast 

Source
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:

modulecratewhat
(root)ghast-clientClient, Behavior, TickContext, the tick loop
protocolghast-protocolpackets per version, framing, compression, encryption, NBT
authghast-authoffline identities, SOCKS5, login crypto, Microsoft accounts
dataghast-datablocks, collision shapes, items, entities
ext (feature ext)ghast-extsequential async helpers: look, dig, place, equip, containers, chat, events
pathfinder (feature pathfinder)ghast-pathfinderphysics-validated A* path planning and following
viewer (feature viewer)ghast-viewerbot 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; with ext also Bot::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§

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.
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).
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.
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 until ghast-physics is integrated.
rotation
Rotation in whole mouse counts.
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.8 scoreboard_team, 1.9 – 1.16.5 teams, 26.x set_player_team).
version
Per-version glue between the generated packets of ghast-protocol and the common layer.
world
Chunk storage for the ghast Minecraft Java Edition client library.

Structs§

BlockHit
A block the crosshair is on.
BlockPos
A block position. x/z must fit 26 signed bits, y 12 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, see join_blocking), also after the swarm is gone.
Buttons
Mouse buttons held in the world (kept until changed; released by a join or respawn).
ChatMessage
A chat message from the server. The text stays raw JSON until asked for.
ClickTicket
A click that was sent: match it with TickEvents::inventory’s clicks on 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.
ClientSettings
Client settings (settings packet), 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.
ProfileKeys
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).
ShutdownReport
What Swarm::shutdown did.
Swarm
Many bots in one process, on one or a few worker threads.
SwarmBuilder
Builder of a Swarm (Swarm::builder).
TeleportEvent
A server teleport / correction (position) with the poses around it.
TickContext
The behaviour’s view of the client during one tick.
TickEvents
What happened since the behaviour’s previous tick.
TickView
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).
WorldTime
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).
ClickRefused
Why TickContext::click (or opening / closing a window) sent nothing.
ClientError
A session failed.
Face
A block face, as in the dig / place packets.
ForceStepPosition
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.
GameMode
Game mode.
GameVersion
A protocol version the client supports, chosen at run time.
PressOutcome
What a press of a button would act on in this tick’s key handling (crate::TickContext::press_preview).
SessionEnd
How a session that reached the play state ended without an error.

Constants§

TICK
Length of one client tick.

Traits§

Behavior
A bot behaviour: the code that decides what the player does each tick.
WorldView
Block access for behaviours, independent of the protocol version.