aboutsummaryrefslogtreecommitdiff
path: root/azalea-core/src
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2026-05-07 01:42:52 -0330
committermat <git@matdoes.dev>2026-05-07 08:05:58 -1200
commitee7358ebc2d3a033b48b3a97af4255e1efba9ef9 (patch)
tree7a69c0676225bab4e37b44fb398829d554708623 /azalea-core/src
parenta6fbdea961c2f8a788b362cbde1eab356d298e84 (diff)
downloadazalea-drasl-ee7358ebc2d3a033b48b3a97af4255e1efba9ef9.tar.xz
correct shapes for blocks with random offsets
Diffstat (limited to 'azalea-core/src')
-rw-r--r--azalea-core/src/math.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/azalea-core/src/math.rs b/azalea-core/src/math.rs
index 1e410cb4..84795368 100644
--- a/azalea-core/src/math.rs
+++ b/azalea-core/src/math.rs
@@ -4,6 +4,8 @@ use std::{
sync::LazyLock,
};
+use crate::position::BlockPos;
+
pub const EPSILON: f64 = 1.0e-7;
// has to be boxed to avoid a stack overflow on windows when run in debug mode
@@ -107,6 +109,18 @@ pub fn equal(a: f64, b: f64) -> bool {
(b - a).abs() < 1.0e-5
}
+/// Hashes the given block position.
+pub fn get_seed(pos: BlockPos) -> i64 {
+ let seed = ((pos.x.wrapping_mul(3129871)) as i64)
+ ^ ((pos.z as i64).wrapping_mul(116129781))
+ ^ (pos.y as i64);
+ let seed = seed
+ .wrapping_mul(seed)
+ .wrapping_mul(42317861)
+ .wrapping_add(seed.wrapping_mul(11));
+ seed >> 16
+}
+
#[cfg(test)]
mod tests {
use super::*;