From 73091d8f937192aca4c4bbc740c78d4d188f6ee1 Mon Sep 17 00:00:00 2001 From: mat Date: Thu, 15 Aug 2024 01:25:11 +0000 Subject: fix sometimes being able to mine blocks through walls --- azalea-core/src/math.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'azalea-core/src') diff --git a/azalea-core/src/math.rs b/azalea-core/src/math.rs index aa9d88c8..7c0ac7b4 100644 --- a/azalea-core/src/math.rs +++ b/azalea-core/src/math.rs @@ -62,6 +62,12 @@ pub fn ceil_log2(x: u32) -> u32 { u32::BITS - x.leading_zeros() } +pub fn fract(x: f64) -> f64 { + let x_int = x as i64 as f64; + let floor = if x < x_int { x_int - 1. } else { x_int }; + x - floor +} + #[cfg(test)] mod tests { use super::*; -- cgit v1.2.3