1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//! Headless Minecraft Java Edition client for the ghast library.
//!
//! - [`Client`]: connect (directly or through a SOCKS5 proxy, see [`ghast_auth::connect`]),
//! handshake, login (offline; online mode with the `microsoft` feature), compression and
//! encryption, then the play state: keep-alives, teleports, window confirms, health,
//! respawn, chat.
//! - A fixed 50 ms tick loop with vanilla 1.8.9's tick order (see [`engine`](crate::TickContext)
//! for the details): inbound packets → [`Behavior::tick`] (actions written immediately) →
//! rotation → movement → exactly one movement packet.
//! - A version-agnostic API: behaviours see [`TickContext`] and the types of [`common`],
//! never packets. The connection is generic over the protocol version
//! ([`version::ClientVersion`]), so each supported version is monomorphised.
//! - Packets nobody needs are dropped before they are decoded; a behaviour opts into more
//! with [`Behavior::interests`].
//!
//! Supported versions: 1.8.9 (protocol 47) and 1.16.5 (protocol 754).
//!
//! ```no_run
//! use ghast_client::{Account, Behavior, Client, GameVersion, Interests, TickContext};
//!
//! struct Echo;
//! impl Behavior for Echo {
//! fn interests(&self) -> Interests {
//! Interests::CHAT
//! }
//! fn tick(&mut self, ctx: &mut TickContext<'_>) {
//! let lines: Vec<String> = ctx.events().chat.iter().map(|m| m.plain()).collect();
//! for line in lines {
//! println!("chat: {line}");
//! }
//! if ctx.is_dead() {
//! ctx.respawn();
//! }
//! }
//! }
//!
//! # async fn run() -> Result<(), Box<dyn std::error::Error>> {
//! let client = Client::new("localhost:25565".parse()?, GameVersion::V1_8_9, Account::offline("Steve")?);
//! let end = client.run(&mut Echo).await?;
//! println!("session ended: {end:?}");
//! # Ok(())
//! # }
//! ```
pub use ;
pub use ;
pub use ;
pub use ;
pub use ghast_entity as entity;
pub use ghast_inventory as inventory;
pub use BlockPos;
pub use ghast_world as world;
pub use ;
pub use Interests;
pub use ;
pub use GameVersion;
/// Re-exports of the connection setup types from `ghast-auth`.