diff --git a/pumpkin-world/src/world_gen/implementation/custom.rs b/pumpkin-world/src/world_gen/implementation/custom.rs index 356d32e2..382b17c4 100644 --- a/pumpkin-world/src/world_gen/implementation/custom.rs +++ b/pumpkin-world/src/world_gen/implementation/custom.rs @@ -4,23 +4,23 @@ use crate::{ block::BlockState, chunk::{ChunkBlocks, ChunkData}, coordinates::Height, - world_gen::{generator::GeneratorInit, WorldGenerator}, + world_gen::WorldGenerator, }; pub struct CustomGenerator { biom: String, - layers: Vec<(u16, u16)>, + layers: Vec<(Height, u16)>, } impl CustomGenerator { - pub fn new(biom: String, layers: &Vec<(i16, String)>) -> Self { + pub fn new(biom: String, layers: &[(i16, String)]) -> Self { Self { biom, layers: layers .iter() .map(|(height, block_id)| { ( - Height(*height).get_absolute(), + Height(*height), BlockState::new(block_id).unwrap().state_id, ) }) @@ -32,6 +32,9 @@ impl CustomGenerator { impl WorldGenerator for CustomGenerator { fn generate_chunk(&self, position: Vector2) -> ChunkData { let mut blocks = ChunkBlocks::default(); + for layer in &self.layers { + blocks.set_layer(layer.0, layer.1); + } ChunkData { position, ..Default::default() diff --git a/pumpkin/src/command/commands/cmd_pumpkin.rs b/pumpkin/src/command/commands/cmd_pumpkin.rs index ae11df23..9afcc6a1 100644 --- a/pumpkin/src/command/commands/cmd_pumpkin.rs +++ b/pumpkin/src/command/commands/cmd_pumpkin.rs @@ -49,8 +49,8 @@ impl CommandExecutor for PumpkinDump { log::info!("Writing dump..."); let mut f = File::create("Dump.txt").await.unwrap(); for (idx, world) in server.worlds.iter().enumerate() { - f.write(format!("World {idx}\n").as_bytes()).await.unwrap(); - f.write(format!("{:?}", world.level).as_bytes()) + f.write_all(format!("World {idx}\n").as_bytes()).await.unwrap(); + f.write_all(format!("{:?}", world.level).as_bytes()) .await .unwrap(); }