Expand description
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.
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);Modules§
- attribute
- The movement speed attribute with its modifiers, evaluated exactly like vanilla’s attribute instance (1.8 and 1.16 share the rules).
- math
- Java-exact numeric helpers.
- modern
- The modern client player movement (26.1 and later), one core generic over a
Rulesrow. - orb
- What an experience orb’s tick reads of the players: every version’s orb follows the nearest
player within 8 blocks (
followNearbyPlayer/ the legacy target search), on the server and on a client alike. - pick
- The crosshair block pick of the voxel-shape versions (1.14 on): which block, face and exact
point the player’s look ray hits (vanilla
BlockGetter.clip/BlockView.raycastwith the outline shape and no fluids, as the client’s crosshair target uses it). - rotation
- Mouse-step rotation as the vanilla client applies it (1.8 renderer +
Entityangle update). - v1_8
- Minecraft 1.8.9 (protocol 47) client player movement.
- v1_12
- Minecraft 1.12.2 (protocol 340) client player movement; the rules hold for every 1.12 release.
- v1_16_5
- Minecraft 1.16.5 (protocol 754) client player movement.
- voxel
- Voxel-grid collision shapes as used from 1.14 on (vanilla
VoxelShape).
Structs§
- Abilities
- The player abilities as both directions of the abilities packet carry them.
- Keys
- Movement keys held during a tick (what the keyboard state would be in vanilla).
- Memory
World - A small in-memory world: explicitly loaded chunk columns, everything else unloaded.
- Packets
- The packets of one tick, in send order. Fixed capacity, no allocation.
- Tick
Input - Everything the player controls for one tick.
- World
Border - The world border as the collision code sees it (centre and current diameter).
Enums§
- Packet
- A movement-related packet the client sends, in the order the tick produced it.