diff options
Diffstat (limited to 'azalea-core/src')
| -rwxr-xr-x | azalea-core/src/direction.rs | 8 | ||||
| -rwxr-xr-x | azalea-core/src/lib.rs | 10 |
2 files changed, 3 insertions, 15 deletions
diff --git a/azalea-core/src/direction.rs b/azalea-core/src/direction.rs index 5a7f601a..95dacc69 100755 --- a/azalea-core/src/direction.rs +++ b/azalea-core/src/direction.rs @@ -1,7 +1,5 @@ use azalea_buf::McBuf; -use crate::floor_mod; - #[derive(Clone, Copy, Debug, McBuf, Default)] pub enum Direction { #[default] @@ -116,7 +114,7 @@ impl AxisCycle { } } pub fn between(axis0: Axis, axis1: Axis) -> Self { - Self::from_ordinal(floor_mod(axis1 as i32 - axis0 as i32, 3)) + Self::from_ordinal(i32::rem_euclid(axis1 as i32 - axis0 as i32, 3) as u32) } pub fn inverse(self) -> Self { match self { @@ -128,8 +126,8 @@ impl AxisCycle { pub fn cycle(self, axis: Axis) -> Axis { match self { Self::None => axis, - Self::Forward => Axis::from_ordinal(floor_mod(axis as i32 + 1, 3)), - Self::Backward => Axis::from_ordinal(floor_mod(axis as i32 - 1, 3)), + Self::Forward => Axis::from_ordinal(i32::rem_euclid(axis as i32 + 1, 3) as u32), + Self::Backward => Axis::from_ordinal(i32::rem_euclid(axis as i32 - 1, 3) as u32), } } pub fn cycle_xyz(self, x: i32, y: i32, z: i32, axis: Axis) -> i32 { diff --git a/azalea-core/src/lib.rs b/azalea-core/src/lib.rs index f7726a38..7c74bdcb 100755 --- a/azalea-core/src/lib.rs +++ b/azalea-core/src/lib.rs @@ -38,16 +38,6 @@ pub use aabb::*; mod block_hit_result; pub use block_hit_result::*; -// java moment -// TODO: add tests and optimize/simplify this -pub fn floor_mod(x: i32, y: u32) -> u32 { - if x < 0 { - y - ((-x) as u32 % y) - } else { - x as u32 % y - } -} - // TODO: make this generic pub fn binary_search(mut min: i32, max: i32, predicate: &dyn Fn(i32) -> bool) -> i32 { let mut diff = max - min; |
