Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generator choosing #461

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
BeautifulPlains,
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_util::{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
12 changes: 9 additions & 3 deletions pumpkin-world/src/generation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,22 @@ 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::BeautifulPlains => Box::new(PlainsGenerator::new(seed)),
_ => todo!(),
}
}

pub mod section_coords {
Expand Down
Loading