diff --git a/pumpkin-world/src/chunk/format/linear.rs b/pumpkin-world/src/chunk/format/linear.rs index 914fb5533..f1bf9e9d1 100644 --- a/pumpkin-world/src/chunk/format/linear.rs +++ b/pumpkin-world/src/chunk/format/linear.rs @@ -327,8 +327,8 @@ impl ChunkSerializer for LinearFile { header.size = chunk_raw.len() as u32; header.timestamp = SystemTime::now() .duration_since(UNIX_EPOCH) - .unwrap() - .as_secs() as u32; + .map(|d| d.as_secs() as u32) + .unwrap_or(0); // We update the data buffer self.chunks_data[index] = Some(chunk_raw); diff --git a/pumpkin-world/src/generation/feature/features/tree/mod.rs b/pumpkin-world/src/generation/feature/features/tree/mod.rs index 7e59e6788..bf96ff48b 100644 --- a/pumpkin-world/src/generation/feature/features/tree/mod.rs +++ b/pumpkin-world/src/generation/feature/features/tree/mod.rs @@ -90,7 +90,7 @@ impl TreeFeature { let clipped_height = self.minimum_size.min_clipped_height; let top = self.get_top(height, chunk, pos); // TODO: roots - if top < height && (clipped_height.is_none() || top < clipped_height.unwrap() as u32) { + if top < height && top < clipped_height.map_or(u32::MAX, |h| h as u32) { return vec![]; } let trunk_state = self.trunk_provider.get(random, pos); diff --git a/pumpkin/src/block/fluid/pathfinder.rs b/pumpkin/src/block/fluid/pathfinder.rs index e095529ea..4d205b615 100644 --- a/pumpkin/src/block/fluid/pathfinder.rs +++ b/pumpkin/src/block/fluid/pathfinder.rs @@ -62,14 +62,11 @@ pub async fn get_spread( continue; } - let new_fluid_state = fluid_impl.get_new_liquid(world, fluid, &side_pos).await; - // Skip if no valid fluid state for this position - if new_fluid_state.is_none() { + let Some(new_fluid_props) = fluid_impl.get_new_liquid(world, fluid, &side_pos).await else { continue; - } + }; - let new_fluid_props = new_fluid_state.unwrap(); let new_state_id = new_fluid_props.to_state_id(fluid); // Holes get distance 0 diff --git a/pumpkin/src/command/args/textcomponent.rs b/pumpkin/src/command/args/textcomponent.rs index eef4fae9a..e0642290d 100644 --- a/pumpkin/src/command/args/textcomponent.rs +++ b/pumpkin/src/command/args/textcomponent.rs @@ -61,11 +61,7 @@ impl FindArg<'_> for TextComponentArgConsumer { } fn parse_text_component(input: &str) -> Option { - let result = serde_json::from_str(input); - if let Err(e) = result { - debug!("Failed to parse text component: {e}"); - None - } else { - result.unwrap() - } + serde_json::from_str(input) + .map_err(|e| debug!("Failed to parse text component: {e}")) + .ok() }