aboutsummaryrefslogtreecommitdiff
path: root/azalea-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-core/src')
-rw-r--r--azalea-core/src/cursor3d.rs6
-rw-r--r--azalea-core/src/math.rs4
2 files changed, 7 insertions, 3 deletions
diff --git a/azalea-core/src/cursor3d.rs b/azalea-core/src/cursor3d.rs
index dc96d890..91a14000 100644
--- a/azalea-core/src/cursor3d.rs
+++ b/azalea-core/src/cursor3d.rs
@@ -71,13 +71,13 @@ impl Cursor3d {
pub fn new(origin: BlockPos, end: BlockPos) -> Self {
let width = (end.x - origin.x + 1)
.try_into()
- .expect("Impossible width.");
+ .unwrap_or_else(|_| panic!("Impossible width, origin: {origin:?}, end: {end:?}"));
let height = (end.y - origin.y + 1)
.try_into()
- .expect("Impossible height.");
+ .unwrap_or_else(|_| panic!("Impossible height, origin: {origin:?}, end: {end:?}"));
let depth = (end.z - origin.z + 1)
.try_into()
- .expect("Impossible depth.");
+ .unwrap_or_else(|_| panic!("Impossible depth, origin: {origin:?}, end: {end:?}"));
Self {
index: 0,
diff --git a/azalea-core/src/math.rs b/azalea-core/src/math.rs
index 105069ef..e62a3d23 100644
--- a/azalea-core/src/math.rs
+++ b/azalea-core/src/math.rs
@@ -92,6 +92,10 @@ pub fn sign_as_int(num: f64) -> i32 {
if num == 0. { 0 } else { num.signum() as i32 }
}
+pub fn equal(a: f64, b: f64) -> bool {
+ (b - a).abs() < 1.0e-5
+}
+
#[cfg(test)]
mod tests {
use super::*;