Skip to content

Commit 3779032

Browse files
authored
Add empty world generator as a config option (#519)
1 parent c754e4f commit 3779032

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

feather/server/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ hash = ""
3131
# The name of the directory containing the world.
3232
name = "world"
3333
# The generator to use if the world does not exist.
34-
# Implemented values are: default, flat
34+
# Implemented values are: default, flat, void
3535
generator = "default"
3636
# The seed to use if the world does not exist.
3737
# Leaving this value empty will generate a random seed.

feather/server/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use common::{Game, TickLoop, World};
66
use ecs::SystemExecutor;
77
use feather_server::{config::Config, Server};
88
use plugin_host::PluginManager;
9-
use worldgen::{ComposableGenerator, SuperflatWorldGenerator, WorldGenerator};
9+
use worldgen::{ComposableGenerator, SuperflatWorldGenerator, VoidWorldGenerator, WorldGenerator};
1010

1111
mod logging;
1212

@@ -70,6 +70,7 @@ fn init_world_source(game: &mut Game, config: &Config) {
7070
"flat" => Arc::new(SuperflatWorldGenerator::new(
7171
SuperflatGeneratorOptions::default(),
7272
)),
73+
"void" => Arc::new(VoidWorldGenerator),
7374
_ => Arc::new(ComposableGenerator::default_with_seed(seed)),
7475
};
7576
game.world = World::with_gen_and_path(generator, config.world.name.clone());

feather/worldgen/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ pub trait WorldGenerator: Send + Sync {
4141
fn generate_chunk(&self, position: ChunkPosition) -> Chunk;
4242
}
4343

44-
pub struct EmptyWorldGenerator {}
44+
pub struct VoidWorldGenerator;
4545

46-
impl WorldGenerator for EmptyWorldGenerator {
46+
impl WorldGenerator for VoidWorldGenerator {
4747
fn generate_chunk(&self, position: ChunkPosition) -> Chunk {
4848
Chunk::new(position)
4949
}
@@ -408,9 +408,9 @@ mod tests {
408408
}
409409

410410
#[test]
411-
pub fn test_worldgen_empty() {
411+
pub fn test_worldgen_void() {
412412
let chunk_pos = ChunkPosition { x: 1, z: 2 };
413-
let generator = EmptyWorldGenerator {};
413+
let generator = VoidWorldGenerator;
414414
let chunk = generator.generate_chunk(chunk_pos);
415415

416416
// No sections have been generated

0 commit comments

Comments
 (0)