#[cfg(any(
feature = "v1_8",
feature = "v1_12",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2",
feature = "v26_3"
))]
use crate::Applied;
#[cfg(any(
feature = "v1_8",
feature = "v1_12",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2",
feature = "v26_3"
))]
#[inline]
pub(crate) fn changed(b: bool) -> Applied {
if b {
Applied::Changed
} else {
Applied::Ignored
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12"))]
pub(crate) const LIGHT_BYTES: usize = 2048;
#[cfg(any(feature = "v1_8", feature = "v1_12"))]
pub(crate) fn same_block_id(a: u16, b: u16) -> bool {
a >> 4 == b >> 4
}
#[cfg(any(feature = "v1_8", feature = "v1_12"))]
pub(crate) fn nibbles(s: &[u8]) -> Box<[u8; LIGHT_BYTES]> {
let mut b = Box::new([0u8; LIGHT_BYTES]);
b.copy_from_slice(s);
b
}
#[cfg(any(
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2",
feature = "v26_3"
))]
#[inline]
pub(crate) fn raw_state_or_air<const STATE_COUNT: usize>(v: i64) -> u16 {
u16::try_from(v)
.ok()
.filter(|&r| usize::from(r) < STATE_COUNT)
.unwrap_or(0)
}
#[cfg(all(
feature = "physics",
any(feature = "v1_8", feature = "v1_12", feature = "v1_16_5")
))]
pub(crate) fn physics_border(b: &crate::Border) -> ghast_physics::WorldBorder {
let (center_x, center_z) = b.center();
ghast_physics::WorldBorder {
center_x,
center_z,
size: b.size(),
}
}