Add a collidable flag to Material
This commit is contained in:
parent
3038596b27
commit
287867dbcd
|
@ -359,7 +359,10 @@ pub enum TintType {
|
|||
define_blocks! {
|
||||
Air {
|
||||
props {},
|
||||
material material::INVISIBLE,
|
||||
material material::Material {
|
||||
collidable: false,
|
||||
.. material::INVISIBLE
|
||||
},
|
||||
model { ("minecraft", "air") },
|
||||
collision vec![],
|
||||
}
|
||||
|
@ -1395,7 +1398,6 @@ define_blocks! {
|
|||
material material::NON_SOLID,
|
||||
model { ("minecraft", "stone_button") },
|
||||
variant format!("facing={},powered={}", facing.as_string(), powered),
|
||||
collision vec![],
|
||||
}
|
||||
SnowLayer {
|
||||
props {
|
||||
|
@ -2535,7 +2537,6 @@ define_blocks! {
|
|||
material material::NON_SOLID,
|
||||
model { ("minecraft", "wooden_button") },
|
||||
variant format!("facing={},powered={}", facing.as_string(), powered),
|
||||
collision vec![],
|
||||
}
|
||||
Skull {
|
||||
props {
|
||||
|
|
|
@ -7,6 +7,7 @@ pub struct Material {
|
|||
pub transparent: bool,
|
||||
pub absorbed_light: u8,
|
||||
pub emitted_light: u8,
|
||||
pub collidable: bool,
|
||||
}
|
||||
|
||||
pub const INVISIBLE: Material = Material {
|
||||
|
@ -17,6 +18,7 @@ pub const INVISIBLE: Material = Material {
|
|||
transparent: false,
|
||||
absorbed_light: 0, // Special because of sky light
|
||||
emitted_light: 0,
|
||||
collidable: true,
|
||||
};
|
||||
|
||||
pub const SOLID: Material = Material {
|
||||
|
@ -27,6 +29,7 @@ pub const SOLID: Material = Material {
|
|||
transparent: false,
|
||||
absorbed_light: 15,
|
||||
emitted_light: 0,
|
||||
collidable: true,
|
||||
};
|
||||
|
||||
pub const NON_SOLID: Material = Material {
|
||||
|
|
|
@ -667,11 +667,13 @@ fn check_collisions(world: &world::World, position: &mut TargetPosition, last_po
|
|||
for z in min_z .. max_z {
|
||||
for x in min_x .. max_x {
|
||||
let block = world.get_block(BPosition::new(x, y, z));
|
||||
for bb in block.get_collision_boxes() {
|
||||
let bb = bb.add_v(cgmath::Vector3::new(x as f64, y as f64, z as f64));
|
||||
if bb.collides(&bounds) {
|
||||
bounds = bounds.move_out_of(bb, dir);
|
||||
hit = true;
|
||||
if block.get_material().collidable {
|
||||
for bb in block.get_collision_boxes() {
|
||||
let bb = bb.add_v(cgmath::Vector3::new(x as f64, y as f64, z as f64));
|
||||
if bb.collides(&bounds) {
|
||||
bounds = bounds.move_out_of(bb, dir);
|
||||
hit = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue