Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOTION_BLOCKING heightmap #523

Merged
merged 13 commits into from
Sep 17, 2023
4 changes: 2 additions & 2 deletions crates/valence_entity/extracted/entities.json
tim-kt marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@
"name": "health",
"index": 9,
"type": "float",
"default_value": 6.0
"default_value": 10.0
},
{
"name": "potion_swirls_color",
Expand Down Expand Up @@ -2863,7 +2863,7 @@
"type": "villager_data",
"default_value": {
"type": "plains",
"profession": "weaponsmith",
"profession": "fletcher",
"level": 1
}
}
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
Loading