aboutsummaryrefslogtreecommitdiff
path: root/azalea-core/src/lib.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2023-07-14 22:20:40 -0500
committerGitHub <noreply@github.com>2023-07-14 22:20:40 -0500
commit7405427199e5a994d4a6a706f84434a69cb7a7d9 (patch)
treeca537e5d761bc053187d952fced0915c850b92aa /azalea-core/src/lib.rs
parentd1afd02aa84e7b4450c1607277f078eb2a0f1bf3 (diff)
downloadazalea-drasl-7405427199e5a994d4a6a706f84434a69cb7a7d9.tar.xz
Mining (#95)
* more mining stuff * initialize azalea-tags crate * more mining stuff 2 * mining in ecs * well technically mining works but no codegen for how long it takes to mine each block yet * rename downloads to __cache__ it was bothering me since it's not *just* downloads * codegen block behavior * fix not sending packet to finish breaking block * mining animation 🎉 * clippy * cleanup, move Client::mine into a client extension * add azalea/src/mining.rs --------- Co-authored-by: mat <git@matdoes.dev>
Diffstat (limited to 'azalea-core/src/lib.rs')
-rwxr-xr-xazalea-core/src/lib.rs63
1 files changed, 3 insertions, 60 deletions
diff --git a/azalea-core/src/lib.rs b/azalea-core/src/lib.rs
index 7bf4a12c..8ed62b06 100755
--- a/azalea-core/src/lib.rs
+++ b/azalea-core/src/lib.rs
@@ -22,8 +22,7 @@ pub use direction::*;
mod delta;
pub use delta::*;
-mod particle;
-pub use particle::*;
+pub mod particle;
mod cursor3d;
pub use cursor3d::*;
@@ -37,61 +36,5 @@ pub use aabb::*;
mod block_hit_result;
pub use block_hit_result::*;
-// some random math things used in minecraft are defined down here
-
-// TODO: make this generic
-pub fn binary_search(mut min: i32, max: i32, predicate: &dyn Fn(i32) -> bool) -> i32 {
- let mut diff = max - min;
- while diff > 0 {
- let diff_mid = diff / 2;
- let mid = min + diff_mid;
- if predicate(mid) {
- diff = diff_mid;
- } else {
- min = mid + 1;
- diff -= diff_mid + 1;
- }
- }
-
- min
-}
-
-pub fn lcm(a: u32, b: u32) -> u64 {
- let gcd = gcd(a, b);
- (a as u64) * (b / gcd) as u64
-}
-pub fn gcd(mut a: u32, mut b: u32) -> u32 {
- while b != 0 {
- let t = b;
- b = a % b;
- a = t;
- }
- a
-}
-
-pub fn lerp<T: num_traits::Float>(amount: T, a: T, b: T) -> T {
- a + amount * (b - a)
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn test_gcd() {
- assert_eq!(gcd(0, 0), 0);
- assert_eq!(gcd(1, 1), 1);
-
- assert_eq!(gcd(0, 1), 1);
- assert_eq!(gcd(1, 0), 1);
-
- assert_eq!(gcd(12, 8), 4);
- assert_eq!(gcd(8, 12), 4);
-
- assert_eq!(gcd(12, 9), 3);
- assert_eq!(gcd(9, 12), 3);
-
- assert_eq!(gcd(12, 7), 1);
- assert_eq!(gcd(7, 12), 1);
- }
-}
+pub mod math;
+pub mod tier;