Skip to content

Commit

Permalink
fix clippy & fix custom
Browse files Browse the repository at this point in the history
  • Loading branch information
suprohub committed Nov 8, 2024
1 parent b9dbcee commit b9c27c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions pumpkin-world/src/world_gen/implementation/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
})
Expand All @@ -32,6 +32,9 @@ impl CustomGenerator {
impl WorldGenerator for CustomGenerator {
fn generate_chunk(&self, position: Vector2<i32>) -> ChunkData {
let mut blocks = ChunkBlocks::default();
for layer in &self.layers {
blocks.set_layer(layer.0, layer.1);
}
ChunkData {
position,
..Default::default()
Expand Down
4 changes: 2 additions & 2 deletions pumpkin/src/command/commands/cmd_pumpkin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit b9c27c0

Please sign in to comment.