Skip to content

Commit

Permalink
add confg
Browse files Browse the repository at this point in the history
  • Loading branch information
suprohub committed Jan 6, 2025
1 parent 6a34f6c commit 16729f3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
10 changes: 10 additions & 0 deletions pumpkin-config/src/generator.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
pub enum Generator {
Test,
Plains,
Superflat,
Void,
Custom,
}
5 changes: 5 additions & 0 deletions pumpkin-config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use generator::Generator;
use log::warn;
use logging::LoggingConfig;
use pumpkin_core::{Difficulty, GameMode, PermissionLvl};
Expand Down Expand Up @@ -25,6 +26,7 @@ pub use pvp::PVPConfig;
pub use server_links::ServerLinksConfig;

mod commands;
pub mod generator;

pub mod op;
mod pvp;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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(),
Expand Down
13 changes: 10 additions & 3 deletions pumpkin-world/src/generation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn WorldGenerator> {
// TODO decide which WorldGenerator to pick based on config.
//Box::new(PlainsGenerator::new(seed))
Box::new(TestGenerator::<TestBiomeGenerator, TestTerrainGenerator>::new(seed))
match BASIC_CONFIG.generator {
Generator::Test => {
Box::new(TestGenerator::<TestBiomeGenerator, TestTerrainGenerator>::new(seed))
}
Generator::Plains => Box::new(PlainsGenerator::new(seed)),
Generator::Void => todo!(),
_ => todo!(),
}
}

pub mod section_coords {
Expand Down

0 comments on commit 16729f3

Please sign in to comment.