From ee7358ebc2d3a033b48b3a97af4255e1efba9ef9 Mon Sep 17 00:00:00 2001 From: mat Date: Thu, 7 May 2026 01:42:52 -0330 Subject: correct shapes for blocks with random offsets --- azalea-core/src/math.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'azalea-core/src/math.rs') 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::*; -- cgit v1.2.3