diff --git a/pumpkin-config/src/generator.rs b/pumpkin-config/src/generator.rs new file mode 100644 index 00000000..b9b5afd2 --- /dev/null +++ b/pumpkin-config/src/generator.rs @@ -0,0 +1,10 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize)] +pub enum Generator { + Test, + Plains, + Superflat, + Void, + Custom, +} diff --git a/pumpkin-config/src/lib.rs b/pumpkin-config/src/lib.rs index 4e6625cc..d39408c1 100644 --- a/pumpkin-config/src/lib.rs +++ b/pumpkin-config/src/lib.rs @@ -1,3 +1,4 @@ +use generator::Generator; use log::warn; use logging::LoggingConfig; use pumpkin_core::{Difficulty, GameMode, PermissionLvl}; @@ -25,6 +26,7 @@ pub use pvp::PVPConfig; pub use server_links::ServerLinksConfig; mod commands; +pub mod generator; pub mod op; mod pvp; @@ -63,6 +65,8 @@ pub struct BasicConfiguration { pub server_address: SocketAddr, /// The seed for world generation. pub seed: String, + /// The world generator for generation. + pub generator: Generator, /// The maximum number of players allowed on the server. Specifying `0` disables the limit. pub max_players: u32, /// The maximum view distance for players. @@ -99,6 +103,7 @@ impl Default for BasicConfiguration { Self { server_address: SocketAddr::new(Ipv4Addr::new(0, 0, 0, 0).into(), 25565), seed: "".to_string(), + generator: Generator::Test, max_players: 100000, view_distance: NonZeroU8::new(10).unwrap(), simulation_distance: NonZeroU8::new(10).unwrap(), diff --git a/pumpkin-world/src/generation/mod.rs b/pumpkin-world/src/generation/mod.rs index 3a901965..37579de9 100644 --- a/pumpkin-world/src/generation/mod.rs +++ b/pumpkin-world/src/generation/mod.rs @@ -17,16 +17,23 @@ mod seed; pub use generator::WorldGenerator; use implementation::{ //overworld::biome::plains::PlainsGenerator, + overworld::biome::plains::PlainsGenerator, test::{TestBiomeGenerator, TestGenerator, TestTerrainGenerator}, }; +use pumpkin_config::{generator::Generator, BASIC_CONFIG}; pub use seed::Seed; use generator::GeneratorInit; pub fn get_world_gen(seed: Seed) -> Box { - // TODO decide which WorldGenerator to pick based on config. - //Box::new(PlainsGenerator::new(seed)) - Box::new(TestGenerator::::new(seed)) + match BASIC_CONFIG.generator { + Generator::Test => { + Box::new(TestGenerator::::new(seed)) + } + Generator::Plains => Box::new(PlainsGenerator::new(seed)), + Generator::Void => todo!(), + _ => todo!(), + } } pub mod section_coords {