#[cfg(feature = "v26_1")]
pub(crate) use ghast_data::v26_1 as shared;
#[cfg(all(feature = "v26_2", not(feature = "v26_1")))]
pub(crate) use ghast_data::v26_2 as shared;
use shared::{StatePhys, VoxelShapeRef};
pub trait Rules: 'static {
type State: Copy + PartialEq;
const PROTOCOL: i32;
const AIR: Self::State;
fn phys(s: Self::State) -> StatePhys;
#[cfg(feature = "v26_1")]
fn block(s: Self::State) -> &'static ghast_data::v26_1::BlockData;
#[cfg(feature = "v26_1")]
#[inline]
fn friction(s: Self::State) -> f32 {
Self::block(s).friction
}
#[cfg(not(feature = "v26_1"))]
fn friction(s: Self::State) -> f32;
#[cfg(feature = "v26_1")]
#[inline]
fn speed_factor(s: Self::State) -> f32 {
Self::block(s).speed_factor
}
#[cfg(not(feature = "v26_1"))]
fn speed_factor(s: Self::State) -> f32;
#[cfg(feature = "v26_1")]
#[inline]
fn jump_factor(s: Self::State) -> f32 {
Self::block(s).jump_factor
}
#[cfg(not(feature = "v26_1"))]
fn jump_factor(s: Self::State) -> f32;
#[cfg(feature = "v26_1")]
#[inline]
fn block_flags(s: Self::State) -> u32 {
Self::block(s).flags
}
#[cfg(not(feature = "v26_1"))]
fn block_flags(s: Self::State) -> u32;
#[cfg(feature = "v26_1")]
#[inline]
fn offset(s: Self::State) -> Option<(f32, f32, bool)> {
Self::block(s).offset
}
#[cfg(not(feature = "v26_1"))]
fn offset(s: Self::State) -> Option<(f32, f32, bool)>;
#[cfg(feature = "v26_1")]
#[inline]
fn block_name(s: Self::State) -> &'static str {
Self::block(s).name
}
#[cfg(not(feature = "v26_1"))]
fn block_name(s: Self::State) -> &'static str;
fn voxel(i: u16) -> &'static VoxelShapeRef;
const FULL_CUBE_VOXEL: u16;
const SCAFFOLDING_BOTTOM_VOXEL: u16;
const POWDER_SNOW_FALLING_VOXEL: u16;
const POSITION_THRESHOLD_SQ: f64;
const POSITION_REMINDER: i32;
const HORIZONTAL_CUTOFF_SQ: f64;
const RESTITUTION: bool = false;
}
#[cfg(feature = "v26_1")]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct V26_1;
#[cfg(feature = "v26_1")]
impl Rules for V26_1 {
type State = ghast_data::v26_1::BlockState;
const PROTOCOL: i32 = 775;
const AIR: Self::State = ghast_data::v26_1::BlockState::AIR;
#[inline]
fn phys(s: Self::State) -> StatePhys {
s.phys()
}
#[inline]
fn block(s: Self::State) -> &'static ghast_data::v26_1::BlockData {
s.block().data()
}
#[inline]
fn voxel(i: u16) -> &'static VoxelShapeRef {
&ghast_data::v26_1::voxel_shapes()[usize::from(i)]
}
const FULL_CUBE_VOXEL: u16 = ghast_data::v26_1::FULL_CUBE_VOXEL;
const SCAFFOLDING_BOTTOM_VOXEL: u16 = ghast_data::v26_1::SCAFFOLDING_BOTTOM_VOXEL;
const POWDER_SNOW_FALLING_VOXEL: u16 = ghast_data::v26_1::POWDER_SNOW_FALLING_VOXEL;
const POSITION_THRESHOLD_SQ: f64 = 2.0e-4 * 2.0e-4;
const POSITION_REMINDER: i32 = 20;
const HORIZONTAL_CUTOFF_SQ: f64 = 9.0e-6;
}
#[cfg(feature = "v26_2")]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct V26_2;
#[cfg(feature = "v26_2")]
impl Rules for V26_2 {
type State = ghast_data::v26_2::BlockState;
const PROTOCOL: i32 = 776;
const AIR: Self::State = ghast_data::v26_2::BlockState::AIR;
#[inline]
fn phys(s: Self::State) -> StatePhys {
s.phys()
}
#[cfg(feature = "v26_1")]
fn block(s: Self::State) -> &'static ghast_data::v26_1::BlockData {
let stone = ghast_data::v26_1::BlockState::from_id(1).map(|s| s.block());
match ghast_data::v26_1::Block::from_name(s.block().name()).or(stone) {
Some(b) => b.data(),
None => ghast_data::v26_1::BlockState::AIR.block().data(),
}
}
#[inline]
fn friction(s: Self::State) -> f32 {
s.block().data().friction
}
#[inline]
fn speed_factor(s: Self::State) -> f32 {
s.block().data().speed_factor
}
#[inline]
fn jump_factor(s: Self::State) -> f32 {
s.block().data().jump_factor
}
#[inline]
fn block_flags(s: Self::State) -> u32 {
s.block().data().flags
}
#[inline]
fn offset(s: Self::State) -> Option<(f32, f32, bool)> {
s.block().data().offset
}
#[inline]
fn block_name(s: Self::State) -> &'static str {
s.block().name()
}
#[inline]
fn voxel(i: u16) -> &'static VoxelShapeRef {
&ghast_data::v26_2::voxel_shapes()[usize::from(i)]
}
const FULL_CUBE_VOXEL: u16 = ghast_data::v26_2::FULL_CUBE_VOXEL;
const SCAFFOLDING_BOTTOM_VOXEL: u16 = ghast_data::v26_2::SCAFFOLDING_BOTTOM_VOXEL;
const POWDER_SNOW_FALLING_VOXEL: u16 = ghast_data::v26_2::POWDER_SNOW_FALLING_VOXEL;
const POSITION_THRESHOLD_SQ: f64 = 2.0e-4 * 2.0e-4;
const POSITION_REMINDER: i32 = 20;
const HORIZONTAL_CUTOFF_SQ: f64 = 9.0e-6;
const RESTITUTION: bool = true;
}