ghast-physics 0.5.5

Vanilla-exact, pure and deterministic player movement for the ghast Minecraft Java Edition client library (1.8.9, 1.12.2, 1.16.5, 26.1, 26.2 and 26.3), verified bit for bit against the real game
Documentation
//! Minecraft 1.8.9 (protocol 47) client player movement.
//!
//! [`tick`] advances a [`PlayerState`] by one client tick against a [`BlockView`] of 1.8 block
//! states and returns the movement packets of that tick. The rules reproduce vanilla 1.8.9's
//! `ClientPlayerEntity` bit for bit (verified against the oracle's golden vectors, see the crate
//! README for coverage).
//!
//! [`BlockView`]: crate::BlockView

mod atan_table;
mod blocks;
mod boat;
mod body;
pub mod drop;
mod fluid;
pub mod launch;
mod minecart;
mod mount;
mod piston;
mod player;
pub mod projectile;
mod ray;

pub use crate::nonliving::Side;

pub use blocks::HistoryShapes;
pub use boat::{
    BOAT_HEIGHT, BOAT_WIDTH, Boat, JavaTrig, StdTrig, boat_item_fits, tick_boat, tick_boat_with,
};
pub use minecart::{MINECART_HEIGHT, MINECART_WIDTH, Minecart, tick_minecart};
pub use mount::{
    HORSE_HEIGHT, HORSE_REARING, HORSE_SADDLED, HORSE_WIDTH, JumpBar, Mount, MountKind, PIG_HEIGHT,
    PIG_WIDTH, tick_mount,
};
pub use piston::{
    Edits, Facing, MOVING_PISTON, MovingBlock, PistonEntity, Pistons, box_is_tracked, search_finds,
    tick_player_among_pistons, tick_with_pistons,
};
pub use player::{
    Effects, HEIGHT, MovementInput, Options, PlayerState, SLEEP_SIZE, STEP_HEIGHT, SentState,
    WIDTH, box_at, is_climbing, is_touching_lava, sleeping_box_at, tick, tick_asleep, tick_with,
};
pub use ray::{RayShape, StairsPasses, no_collision_box, no_collision_box_at, ray_shape};

/// The 1.8 block state the world view returns (re-exported from `ghast-data`).
pub use ghast_data::v1_8::BlockState;

use crate::input::{Packets, TickInput};
use crate::world::BlockView;

/// The 1.8.9 rule set as a type, for code generic over versions (see [`crate::Ruleset`]).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct V1_8;

impl crate::Ruleset for V1_8 {
    type BlockState = BlockState;
    type Player = PlayerState;
    type Options = Options;

    #[inline]
    fn tick_with<W: BlockView<State = BlockState>>(
        player: &mut PlayerState,
        input: &TickInput,
        world: &W,
        options: &Options,
        out: &mut Packets,
    ) {
        tick_with(player, input, world, options, out);
    }
}

/// A [`crate::MemoryWorld`] of 1.8 block states (raw values decoded the vanilla way).
pub type MemoryWorld = crate::MemoryWorld<BlockState>;

/// An empty 1.8 [`MemoryWorld`] (nothing loaded).
#[must_use]
pub fn memory_world() -> MemoryWorld {
    crate::MemoryWorld::new(BlockState::from_raw_vanilla)
}

#[cfg(test)]
mod tests;