ghast-physics 0.5.1

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.16.5 (protocol 754) client player movement.
//!
//! Same calling convention as [`crate::v1_8`]; the state carries 1.16's extra movement state
//! (pose, swimming, fluid heights, motion multiplier). Collision uses voxel-grid shapes
//! ([`crate::voxel`]).

mod blocks;
mod boat;
mod collide;
mod entity;
mod ext;
mod fluid;
mod minecart;
mod piston;
mod piston_shapes;
mod piston_updates;
mod player;

pub use blocks::{CollisionContext, state_collides};
pub use boat::{BOAT_HEIGHT, BOAT_WIDTH, Boat, BoatLocation, boat_item_fits, tick_boat};
pub use entity::{
    OtherEntity, PushKind, Pusher, Surroundings, climbing_at, collides, hits_pushable, push_by,
    push_kind, pushable, query_reaches, step_height,
};
pub use ext::PlayerExt;
/// The 1.16.5 block state the world view returns (re-exported from `ghast-data`).
pub use ghast_data::v1_16_5::BlockState;
pub use minecart::{MINECART_HEIGHT, MINECART_WIDTH, Minecart, tick_minecart};
pub use piston::{
    Edits, Facing, MovingBlock, PistonCarry, PistonEntity, Pistons, PlayerPlace, search_finds,
    tick_player_among_pistons, tick_with_pistons,
};
#[allow(deprecated)]
pub use piston::{edits_need_shape_updates, follows_neighbours};
pub use player::{
    Effects, Enchantments, MovementInput, PlayerState, Pose, STEP_HEIGHT, SentState,
    SpeedModifiers, WIDTH, box_at, in_water_or_rain, is_climbing, riptide, rocket_boost, tick,
    tick_ext, tick_in,
};

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

/// The 1.16.5 rule set as a type (see [`crate::Ruleset`]).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct V1_16_5;

/// 1.16.5 has no rule options yet.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct Options {}

impl crate::Ruleset for V1_16_5 {
    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(player, input, world, out);
    }
}

/// A [`crate::MemoryWorld`] of 1.16.5 block states (global palette ids).
pub type MemoryWorld = crate::MemoryWorld<BlockState>;

/// An empty 1.16.5 [`MemoryWorld`]; unknown ids decode to air.
#[must_use]
pub fn memory_world() -> MemoryWorld {
    crate::MemoryWorld::new(|raw| BlockState::from_id(raw).unwrap_or(BlockState::AIR))
}

#[cfg(test)]
mod tests;