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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//! Vanilla-exact player movement for the ghast Minecraft Java Edition client library.
//!
//! The crate is a **pure, deterministic function**: `(player state, input, world view) -> new
//! player state + the movement packets of the tick`. No IO, no async, no clock, no global mutable
//! state (the only static is vanilla's constant sine table). The same code path serves the live
//! client, trace replays and look-ahead planning (copy the state, simulate, discard).
//!
//! Rules are per protocol version, each in its own module selected at compile time:
//!
//! | module | version | status |
//! |---|---|---|
//! | [`v1_8`] | 1.8.9 (protocol 47; also 1.8.2 – 1.8.8) | bit-exact against the vanilla oracle |
//! | [`v1_12`] | 1.12.2 (protocol 340; also 1.12.1) | bit-exact against the vanilla oracle |
//! | [`v1_16_5`] | 1.16.5 (protocol 754; also 1.16.2 – 1.16.4) | bit-exact against the vanilla oracle |
//! | [`modern`] (`V26_1`) | 26.1 (protocol 775) | bit-exact against the vanilla oracle |
//! | [`modern`] (`V26_2`) | 26.2 (protocol 776) | bit-exact against the vanilla oracle |
//! | [`modern`] (`V26_3`) | 26.3 (protocol 777) | bit-exact against the vanilla oracle |
//!
//! Code that is generic over versions uses the [`Ruleset`] trait (static dispatch, no runtime
//! cost).
//!
//! [`pick`] is the crosshair target (block, face, hit point, or entity) for 1.8.9, 1.12.2,
//! 1.16.5, 26.1, 26.2 and 26.3.
//!
//! ```
//! # #[cfg(feature = "v1_8")] {
//! use ghast_physics::{Keys, Packets, TickInput, v1_8};
//!
//! let mut world = v1_8::memory_world();
//! world.load_chunks(-1, -1, 0, 0);
//! world.fill_raw([-16, 63, -16], [15, 63, 15], 1 << 4); // stone floor
//! let mut player = v1_8::PlayerState::new([0.5, 64.0, 0.5], 0.0, 0.0);
//! let mut out = Packets::new();
//! let keys = Keys { forward: true, ..Keys::NONE };
//! let input = TickInput { keys, yaw: 0.0, pitch: 0.0, using_item: false };
//! for _ in 0..20 {
//! out.clear();
//! v1_8::tick(&mut player, &input, &world, &mut out);
//! }
//! assert!(player.on_ground && player.pos[2] > 2.0);
//! # }
//! ```
pub use ;
pub use ;
/// A version's movement rules, for code generic over protocol versions.