aboutsummaryrefslogtreecommitdiff
path: root/azalea-block/src
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-block/src')
-rw-r--r--azalea-block/src/range.rs25
1 files changed, 21 insertions, 4 deletions
diff --git a/azalea-block/src/range.rs b/azalea-block/src/range.rs
index 7960b5c4..76b18079 100644
--- a/azalea-block/src/range.rs
+++ b/azalea-block/src/range.rs
@@ -3,6 +3,8 @@ use std::{
ops::{Add, RangeInclusive},
};
+use azalea_registry::Block;
+
use crate::{BlockState, block_state::BlockStateIntegerRepr};
#[derive(Debug, Clone)]
@@ -45,14 +47,14 @@ impl Add for BlockStates {
}
}
-impl From<HashSet<azalea_registry::Block>> for BlockStates {
- fn from(set: HashSet<azalea_registry::Block>) -> Self {
+impl From<HashSet<Block>> for BlockStates {
+ fn from(set: HashSet<Block>) -> Self {
Self::from(&set)
}
}
-impl From<&HashSet<azalea_registry::Block>> for BlockStates {
- fn from(set: &HashSet<azalea_registry::Block>) -> Self {
+impl From<&HashSet<Block>> for BlockStates {
+ fn from(set: &HashSet<Block>) -> Self {
let mut block_states = HashSet::with_capacity(set.len());
for &block in set {
block_states.extend(BlockStates::from(block));
@@ -60,3 +62,18 @@ impl From<&HashSet<azalea_registry::Block>> for BlockStates {
Self { set: block_states }
}
}
+
+impl<const N: usize> From<[Block; N]> for BlockStates {
+ fn from(arr: [Block; N]) -> Self {
+ Self::from(&arr[..])
+ }
+}
+impl From<&[Block]> for BlockStates {
+ fn from(arr: &[Block]) -> Self {
+ let mut block_states = HashSet::with_capacity(arr.len());
+ for &block in arr {
+ block_states.extend(BlockStates::from(block));
+ }
+ Self { set: block_states }
+ }
+}