diff --git a/pomme-client/src/world/block/mod.rs b/pomme-client/src/world/block/mod.rs index 37153791..3daff75f 100644 --- a/pomme-client/src/world/block/mod.rs +++ b/pomme-client/src/world/block/mod.rs @@ -1610,6 +1610,29 @@ mod tests { assert_eq!(light_props(BlockState::AIR).dampening, 0); } + #[test] + fn can_occlude_follows_no_occlusion() { + setup(); + for (name, occludes) in [ + ("copper_grate", false), + ("waxed_oxidized_copper_grate", false), + ("test_instance_block", false), + ("glass", false), + ("oak_leaves", false), + ("ice", false), + ("stone", true), + ("packed_ice", true), + ("blue_ice", true), + ("copper_block", true), + ] { + assert_eq!( + light_props(find_state(name, &[])).can_occlude, + occludes, + "{name}" + ); + } + } + #[test] fn slab_face_occlusion() { setup(); diff --git a/pomme-client/src/world/block/model.rs b/pomme-client/src/world/block/model.rs index 656d95ec..5973de9c 100644 --- a/pomme-client/src/world/block/model.rs +++ b/pomme-client/src/world/block/model.rs @@ -359,9 +359,6 @@ pub struct BakedQuad { pub struct BakedModel { pub quads: Vec, pub is_full_cube: bool, - /// Vanilla `canOcclude`: full cubes occlude, but cutout blocks like leaves - /// don't, so neighbor faces against them still render. - pub occludes: bool, } #[derive(Clone)] @@ -456,12 +453,9 @@ pub fn bake_all_models( &mut model_cache, packs, ); - if let Some(mut baked) = + if let Some(baked) = bake_resolved_model(&resolved, model_ref.x, model_ref.y, block_tint) { - if is_non_occluding(block_name) { - baked.occludes = false; - } variants_map.insert(variant_key.clone(), baked); } } @@ -637,7 +631,6 @@ pub fn bake_item_models( Some(mut model) => { model.quads.extend(baked.quads); model.is_full_cube = false; - model.occludes = false; model } }); @@ -774,7 +767,6 @@ fn bake_chest_item_model(gui: DisplayTransform, gui_light: GuiLight) -> BakedMod BakedModel { quads, is_full_cube: false, - occludes: false, } } @@ -1518,11 +1510,9 @@ fn bake_resolved_model( return None; } - let is_full_cube = check_full_cube(&quads); Some(BakedModel { + is_full_cube: check_full_cube(&quads), quads, - is_full_cube, - occludes: is_full_cube, }) } @@ -1815,14 +1805,6 @@ fn face_textures_base( None } -/// Full-cube blocks that mustn't cull adjacent faces (vanilla `noOcclusion`). -/// Solid `packed_ice`/`blue_ice` still occlude, so `ice` is matched exactly. -fn is_non_occluding(block_name: &str) -> bool { - block_name.ends_with("_leaves") - || block_name.ends_with("_stained_glass") - || matches!(block_name, "glass" | "tinted_glass" | "ice" | "frosted_ice") -} - fn determine_tint(block_name: &str) -> Tint { if block_name == "redstone_wire" { Tint::Redstone diff --git a/pomme-client/src/world/block/registry.rs b/pomme-client/src/world/block/registry.rs index d91ca82e..d7640be2 100644 --- a/pomme-client/src/world/block/registry.rs +++ b/pomme-client/src/world/block/registry.rs @@ -217,22 +217,14 @@ impl BlockRegistry { if quads.is_empty() { None } else { Some(quads) } } - fn baked_model_flag(&self, state: BlockState, f: impl Fn(&BakedModel) -> bool) -> bool { - if super::is_air(state) { - return false; - } - self.get_baked_model(state).map(f).unwrap_or(false) - } - pub fn is_opaque_full_cube(&self, state: BlockState) -> bool { - self.baked_model_flag(state, |m| m.is_full_cube) + !super::is_air(state) && self.get_baked_model(state).is_some_and(|m| m.is_full_cube) } - /// Whether `state` culls a neighbor's adjacent face. Unlike - /// [`Self::is_opaque_full_cube`], non-occluding blocks like leaves return - /// false even though they bake as full cubes. + /// Whether `state` culls a neighbor's adjacent face: a full cube that can + /// occlude, so `noOcclusion` cubes like glass and leaves don't. pub fn occludes_neighbor(&self, state: BlockState) -> bool { - self.baked_model_flag(state, |m| m.occludes) + self.is_opaque_full_cube(state) && super::light_props(state).can_occlude } pub fn texture_names(&self) -> impl Iterator + '_ {