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

Supported versions: 1.8.9 and 1.16.5. See the afk and chat examples:

cargo run -p ghast --example afk -- --host localhost --port 25565 --username Bot --version 1.8.9

Re-exports§

pub use ghast_protocol as protocol;
pub use ghast_auth as auth;
pub use ghast_data as data;

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.
entity
Entity tracking for the ghast Minecraft Java Edition client library (1.8.9 and 1.16.5).
hands
The mouse buttons in the world: digging, placing and using items, ported from 1.8.9 MinecraftClient.tick (doAttack, doUse, handleBlockBreaking) and ClientPlayerInteractionManager (attackBlock, updateBlockBreakingProgress, cancelBlockBreaking, onRightClick, interactItem, stopUsingItem), verified against recorded lab packet traces.
inventory
Inventory and container windows for the ghast Minecraft Java Edition client library (1.8.9 and 1.16.5).
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.
version
Per-version glue between the generated packets of ghast-protocol and the common layer.

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.
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.
RawInbound
A clientbound play packet copied for the behaviour (Behavior::raw_packets).
TickContext
The behaviour’s view of the client during one tick.
TickEvents
What happened since the behaviour’s previous tick.
Vec3
A position or direction in world space.

Enums§

Account
The account a client logs in with.
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. See crates/ghast-physics/GRIM_NOTES.md.
GameMode
Game mode.
GameVersion
A protocol version the client supports, chosen at run time.
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.