diff --git a/pumpkin-world/src/chunk/anvil.rs b/pumpkin-world/src/chunk/anvil.rs index af24f70b..4e83c078 100644 --- a/pumpkin-world/src/chunk/anvil.rs +++ b/pumpkin-world/src/chunk/anvil.rs @@ -218,7 +218,7 @@ mod tests { use pumpkin_core::math::vector2::Vector2; use crate::{ - chunk::{anvil::AnvilChunkReader, ChunkReader, ChunkReadingError}, + chunk::{anvil::AnvilChunkReader, ChunkReader, ChunkReadingError, WorldInfo}, level::SaveFile, }; @@ -234,4 +234,20 @@ mod tests { ); assert!(matches!(result, Err(ChunkReadingError::ChunkNotExist))); } + + #[test] + fn test_level_dat_reading() { + let world_loader = AnvilChunkReader::new(); + let root_folder = PathBuf::from("test-files").join("sample-1"); + let save_file = SaveFile { + root_folder: root_folder.clone(), + region_folder: root_folder, + }; + let expected = WorldInfo { + seed: -79717552349559436, + }; + let info = world_loader.read_world_info(&save_file).unwrap(); + + assert_eq!(info, expected); + } } diff --git a/pumpkin-world/src/chunk/mod.rs b/pumpkin-world/src/chunk/mod.rs index 5e69e8f6..7d50c4d4 100644 --- a/pumpkin-world/src/chunk/mod.rs +++ b/pumpkin-world/src/chunk/mod.rs @@ -328,6 +328,7 @@ pub enum ChunkParsingError { ErrorDeserializingChunk(String), } +#[derive(Debug, PartialEq)] pub struct WorldInfo { pub seed: i64, // TODO: Implement all fields diff --git a/pumpkin-world/test-files/sample-1/level.dat b/pumpkin-world/test-files/sample-1/level.dat new file mode 100644 index 00000000..1a527907 Binary files /dev/null and b/pumpkin-world/test-files/sample-1/level.dat differ