pub struct Client { /* private fields */ }Expand description
A configured client: where to connect, which version, which account, and how.
One Client can run any number of sessions one after another (reconnects); run several
clients concurrently for several bots (one per process, or many tasks in one process —
a failing session never affects another).
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(address: TargetAddr, version: GameVersion, account: Account) -> Self
pub fn new(address: TargetAddr, version: GameVersion, account: Account) -> Self
A client with vanilla defaults: direct connection (see Client::connector),
brand vanilla, sensitivity 0.5, 30 s read timeout.
Sourcepub fn connector(self, connector: Connector) -> Self
pub fn connector(self, connector: Connector) -> Self
How to open the TCP connection (SOCKS5 proxy, proxy policy, timeouts).
Sourcepub fn settings(self, settings: ClientSettings) -> Self
pub fn settings(self, settings: ClientSettings) -> Self
Client settings sent after joining.
Sourcepub fn brand(self, brand: Option<String>) -> Self
pub fn brand(self, brand: Option<String>) -> Self
The client brand sent after joining (None: send none).
Sourcepub fn sensitivity(self, sensitivity: f32) -> Self
pub fn sensitivity(self, sensitivity: f32) -> Self
Mouse sensitivity (options.txt value, 0 … 1) for rotation steps.
Sourcepub fn silent_hold(self, d: Duration) -> Self
pub fn silent_hold(self, d: Duration) -> Self
The behaviour is frozen after this long without data from the server (default 1.5 s).
Sourcepub fn read_timeout(self, d: Duration) -> Self
pub fn read_timeout(self, d: Duration) -> Self
The session fails after this long without data from the server (default 30 s, like vanilla’s read timeout).
Sourcepub fn login_timeout(self, d: Duration) -> Self
pub fn login_timeout(self, d: Duration) -> Self
Connecting plus login must finish within this time (default 30 s).
Sourcepub fn record(self, path: impl Into<PathBuf>) -> Self
pub fn record(self, path: impl Into<PathBuf>) -> Self
Records every session’s movement in the oracle’s replay format (1.8.9; the file is overwritten by each session). For debugging anticheat flags against vanilla.
Sourcepub fn world_config(self, config: WorldConfig) -> Self
pub fn world_config(self, config: WorldConfig) -> Self
What the world keeps besides block states. Default: nothing (no light, no biomes:
the bot does not need them, and they cost memory and decoding time). A viewer that
draws the world can turn them on; crate::WorldView::column gives the data.
Sourcepub fn hold_turn_on_action(self, on: bool) -> Self
pub fn hold_turn_on_action(self, on: bool) -> Self
Keep the look still on a tick that dug or placed when this tick’s turn would take the crosshair off the clicked block (on by default). Grim’s RotationPlace re-checks a dig / place with the look of the movement packet that follows it; holding the mouse for one tick is what a player does anyway. The held turn continues on the next tick the behaviour aims.
Sourcepub fn force_step_position(self, on: bool) -> Self
pub fn force_step_position(self, on: bool) -> Self
Not vanilla (Grim 2.3 compatibility, off by default): on a tick whose feet height changed (a step-up or landing) but whose move stayed under the 0.03-block resend threshold, send the position anyway. Vanilla sends only the look / on-ground there, which Grim 2.3.73 sets back (soul sand → grass hops).
Sourcepub fn force_step_position_mode(self, mode: ForceStepPosition) -> Self
pub fn force_step_position_mode(self, mode: ForceStepPosition) -> Self
Not vanilla: Client::force_step_position with a choice of rule, e.g.
ForceStepPosition::StepUpOnly, which forces the
position only on step-ups (on ground after the move, feet higher) and leaves sub-0.03
falls and landings vanilla.
Sourcepub fn address(&self) -> &TargetAddr
pub fn address(&self) -> &TargetAddr
The server address.
Sourcepub fn version(&self) -> GameVersion
pub fn version(&self) -> GameVersion
The protocol version.
Sourcepub async fn run<B: Behavior>(
&self,
behavior: &mut B,
) -> Result<SessionEnd, ClientError>
pub async fn run<B: Behavior>( &self, behavior: &mut B, ) -> Result<SessionEnd, ClientError>
Runs one session with behavior until the server ends it, the behaviour quits or an
error occurs.
Sourcepub async fn run_until<B, S>(
&self,
behavior: &mut B,
shutdown: S,
) -> Result<SessionEnd, ClientError>
pub async fn run_until<B, S>( &self, behavior: &mut B, shutdown: S, ) -> Result<SessionEnd, ClientError>
Like Client::run, but also ends cleanly (the behaviour is stopped, the socket shut
down) when shutdown completes.