Fix clippy::manual_flatten, use flatten()

This commit is contained in:
ice_iix 2021-06-18 15:04:41 -07:00
parent d15229dd0b
commit 53a0bc9fb6
1 changed files with 22 additions and 24 deletions

View File

@ -1902,31 +1902,29 @@ impl Server {
} }
fn load_block_entities(&mut self, block_entities: Vec<Option<crate::nbt::NamedTag>>) { fn load_block_entities(&mut self, block_entities: Vec<Option<crate::nbt::NamedTag>>) {
for optional_block_entity in block_entities { for block_entity in block_entities.into_iter().flatten() {
if let Some(block_entity) = optional_block_entity { let x = block_entity.1.get("x").unwrap().as_int().unwrap();
let x = block_entity.1.get("x").unwrap().as_int().unwrap(); let y = block_entity.1.get("y").unwrap().as_int().unwrap();
let y = block_entity.1.get("y").unwrap().as_int().unwrap(); let z = block_entity.1.get("z").unwrap().as_int().unwrap();
let z = block_entity.1.get("z").unwrap().as_int().unwrap(); if let Some(tile_id) = block_entity.1.get("id") {
if let Some(tile_id) = block_entity.1.get("id") { let tile_id = tile_id.as_str().unwrap();
let tile_id = tile_id.as_str().unwrap(); let action;
let action; match tile_id {
match tile_id { // Fake a sign update
// Fake a sign update "Sign" => action = 9,
"Sign" => action = 9, // Not something we care about, so break the loop
// Not something we care about, so break the loop _ => continue,
_ => continue,
}
self.on_block_entity_update(packet::play::clientbound::UpdateBlockEntity {
location: Position::new(x, y, z),
action,
nbt: Some(block_entity.clone()),
});
} else {
warn!(
"Block entity at ({},{},{}) missing id tag: {:?}",
x, y, z, block_entity
);
} }
self.on_block_entity_update(packet::play::clientbound::UpdateBlockEntity {
location: Position::new(x, y, z),
action,
nbt: Some(block_entity.clone()),
});
} else {
warn!(
"Block entity at ({},{},{}) missing id tag: {:?}",
x, y, z, block_entity
);
} }
} }
} }