diff options
| author | mat <git@matdoes.dev> | 2024-12-24 08:48:36 +0000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2024-12-24 08:48:36 +0000 |
| commit | f03e0c22355778a9863cccb5a59d852278d60701 (patch) | |
| tree | f02e7ca3d1e975d486071934a6322d372b7c9a02 /azalea/src/pathfinder/mining.rs | |
| parent | de5a53ce08de5b9d77bce99dd9ecde3171ebd74e (diff) | |
| download | azalea-drasl-f03e0c22355778a9863cccb5a59d852278d60701.tar.xz | |
fix parsing Dust particle and treat waterlogged blocks as liquid in pathfinder
Diffstat (limited to 'azalea/src/pathfinder/mining.rs')
| -rw-r--r-- | azalea/src/pathfinder/mining.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/azalea/src/pathfinder/mining.rs b/azalea/src/pathfinder/mining.rs index 31b37b49..049e974a 100644 --- a/azalea/src/pathfinder/mining.rs +++ b/azalea/src/pathfinder/mining.rs @@ -1,6 +1,7 @@ use std::{cell::UnsafeCell, ops::RangeInclusive}; -use azalea_block::{BlockState, BlockStates}; +use azalea_block::{properties::Waterlogged, BlockState, BlockStates}; +use azalea_core::bitset::BitSet; use azalea_inventory::Menu; use nohash_hasher::IntMap; @@ -96,8 +97,12 @@ impl MiningCache { } pub fn is_liquid(&self, block: BlockState) -> bool { + // this already runs in about 1 nanosecond, so if you wanna try optimizing it at + // least run the benchmarks (in benches/checks.rs) + self.water_block_state_range.contains(&block.id) || self.lava_block_state_range.contains(&block.id) + || is_waterlogged(block) } pub fn is_falling_block(&self, block: BlockState) -> bool { @@ -106,3 +111,7 @@ impl MiningCache { .is_ok() } } + +pub fn is_waterlogged(block: BlockState) -> bool { + block.property::<Waterlogged>().unwrap_or_default() +} |
