Skip to main content

Client

Struct Client 

Source
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

Source

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.

Source

pub fn connector(self, connector: Connector) -> Self

How to open the TCP connection (SOCKS5 proxy, proxy policy, timeouts).

Source

pub fn settings(self, settings: ClientSettings) -> Self

Client settings sent after joining.

Source

pub fn brand(self, brand: Option<String>) -> Self

The client brand sent after joining (None: send none).

Source

pub fn sensitivity(self, sensitivity: f32) -> Self

Mouse sensitivity (options.txt value, 0 … 1) for rotation steps.

Source

pub fn silent_hold(self, d: Duration) -> Self

The behaviour is frozen after this long without data from the server (default 1.5 s).

Source

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).

Source

pub fn login_timeout(self, d: Duration) -> Self

Connecting plus login must finish within this time (default 30 s).

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

pub fn address(&self) -> &TargetAddr

The server address.

Source

pub fn version(&self) -> GameVersion

The protocol version.

Source

pub fn account(&self) -> &Account

The account.

Source

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.

Source

pub async fn run_until<B, S>( &self, behavior: &mut B, shutdown: S, ) -> Result<SessionEnd, ClientError>
where B: Behavior, S: Future<Output = ()>,

Like Client::run, but also ends cleanly (the behaviour is stopped, the socket shut down) when shutdown completes.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Client

§

impl !UnwindSafe for Client

§

impl Forget for Client

§

impl Freeze for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl UnsafeUnpin for Client

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more