diff --git a/pumpkin-world/src/lib.rs b/pumpkin-world/src/lib.rs index 56462faf8..bad06b925 100644 --- a/pumpkin-world/src/lib.rs +++ b/pumpkin-world/src/lib.rs @@ -10,6 +10,7 @@ pub mod item; mod level; pub mod radial_chunk_iterator; pub mod vector3; +mod world_gen; pub const WORLD_HEIGHT: usize = 384; pub const WORLD_LOWEST_Y: i16 = -64; diff --git a/pumpkin-world/src/world_gen/mod.rs b/pumpkin-world/src/world_gen/mod.rs new file mode 100644 index 000000000..1db8d3c21 --- /dev/null +++ b/pumpkin-world/src/world_gen/mod.rs @@ -0,0 +1 @@ +mod seed; diff --git a/pumpkin-world/src/world_gen/seed.rs b/pumpkin-world/src/world_gen/seed.rs new file mode 100644 index 000000000..a3245c2b6 --- /dev/null +++ b/pumpkin-world/src/world_gen/seed.rs @@ -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) + } +}