Added Seed Type.

This commit is contained in:
DaniD3v 2024-08-27 23:12:02 +02:00
parent eb4d47aa74
commit 4031c4dc13
3 changed files with 18 additions and 0 deletions

View File

@ -10,6 +10,7 @@ pub mod item;
mod level; mod level;
pub mod radial_chunk_iterator; pub mod radial_chunk_iterator;
pub mod vector3; pub mod vector3;
mod world_gen;
pub const WORLD_HEIGHT: usize = 384; pub const WORLD_HEIGHT: usize = 384;
pub const WORLD_LOWEST_Y: i16 = -64; pub const WORLD_LOWEST_Y: i16 = -64;

View File

@ -0,0 +1 @@
mod seed;

View File

@ -0,0 +1,16 @@
use std::hash::{DefaultHasher, Hash, Hasher};
#[allow(dead_code)]
#[derive(Clone, Copy)]
pub struct Seed(pub i64);
impl From<&str> for Seed {
fn from(value: &str) -> Self {
// TODO replace with a deterministic hasher (the same as vanilla?)
let mut hasher = DefaultHasher::new();
value.hash(&mut hasher);
// TODO use cast_signed once the feature is stabilized.
Self(hasher.finish() as i64)
}
}