aboutsummaryrefslogtreecommitdiff
path: root/azalea-core/src
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2024-08-15 01:25:11 +0000
committermat <git@matdoes.dev>2024-08-15 01:25:11 +0000
commit73091d8f937192aca4c4bbc740c78d4d188f6ee1 (patch)
tree440e804d3a84583fb1b6b43a47724f5a17d001b7 /azalea-core/src
parentdec544a52ba738e2d0e2c3a042e5ccc0cb336ffb (diff)
downloadazalea-drasl-73091d8f937192aca4c4bbc740c78d4d188f6ee1.tar.xz
fix sometimes being able to mine blocks through walls
Diffstat (limited to 'azalea-core/src')
-rw-r--r--azalea-core/src/math.rs6
1 files changed, 6 insertions, 0 deletions
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::*;