From 67ebdfac7243ef33af05713775e21e1e72b59a3d Mon Sep 17 00:00:00 2001 From: ErrorNoInternet Date: Mon, 3 Mar 2025 07:41:35 -0500 Subject: [PATCH] refactor(block): clean up variables --- src/lua/block.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/lua/block.rs b/src/lua/block.rs index 32e978d..12ba1ea 100644 --- a/src/lua/block.rs +++ b/src/lua/block.rs @@ -43,21 +43,24 @@ pub async fn get_block_states( ) -> Result> { let mut matched = Vec::new(); for block_name in block_names { - for b in + for block in (u32::MIN..u32::MAX).map_while(|possible_id| BlockState::try_from(possible_id).ok()) { - if block_name == Into::>::into(b).id() + if block_name == Into::>::into(block).id() && (if let Some(filter_fn) = &filter_fn { - let p = lua.create_table()?; - p.set("chest_type", b.property::().map(|v| v as u8))?; - p.set("facing", b.property::().map(|v| v as u8))?; - p.set("light_level", b.property::().map(|v| v as u8))?; - filter_fn.call_async::(p.clone()).await? + let table = lua.create_table()?; + table.set("chest_type", block.property::().map(|v| v as u8))?; + table.set("facing", block.property::().map(|v| v as u8))?; + table.set( + "light_level", + block.property::().map(|v| v as u8), + )?; + filter_fn.call_async::(table).await? } else { true }) { - matched.push(b.id); + matched.push(block.id); } } }