Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/command_api' into command_api
Browse files Browse the repository at this point in the history
  • Loading branch information
JackCrumpLeys committed Sep 25, 2023
2 parents 5461332 + 8bf60b7 commit 624d864
Show file tree
Hide file tree
Showing 11 changed files with 24,483 additions and 18 deletions.
4 changes: 2 additions & 2 deletions crates/valence_anvil/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,7 @@ impl Region {
)
});

let mut used_sectors = bitvec::vec::BitVec::new();
used_sectors[0..2].fill(true);
let mut used_sectors = bitvec::vec::BitVec::repeat(true, 2);
for location in locations {
if location.is_none() {
// No chunk exists at this position.
Expand Down Expand Up @@ -690,6 +689,7 @@ impl Region {
let end_index = sector_offset as usize + sector_count;
if used_sectors.len() < end_index {
used_sectors.resize(start_index, false);
used_sectors.resize(end_index, true);
} else {
used_sectors[start_index..end_index].fill(true);
}
Expand Down
20 changes: 20 additions & 0 deletions crates/valence_generated/build/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct State {
luminance: u8,
opaque: bool,
replaceable: bool,
blocks_motion: bool,
collision_shapes: Vec<u16>,
block_entity_type: Option<u32>,
}
Expand Down Expand Up @@ -149,6 +150,18 @@ pub fn build() -> anyhow::Result<TokenStream> {
})
.collect::<TokenStream>();

let state_to_blocks_motion_arms = blocks
.iter()
.flat_map(|b| {
b.states.iter().filter(|s| s.blocks_motion).map(|s| {
let id = s.id;
quote! {
#id => true,
}
})
})
.collect::<TokenStream>();

let shapes = shapes.iter().map(|s| {
let min_x = s.min_x;
let min_y = s.min_y;
Expand Down Expand Up @@ -672,6 +685,13 @@ pub fn build() -> anyhow::Result<TokenStream> {
}
}

pub const fn blocks_motion(self) -> bool {
match self.0 {
#state_to_blocks_motion_arms
_ => false,
}
}

const SHAPES: [Aabb; #shape_count] = [
#(#shapes,)*
];
Expand Down
Loading

0 comments on commit 624d864

Please sign in to comment.