From ac33fb74ece1bc40ac7c6e28fc69acfdd20ef023 Mon Sep 17 00:00:00 2001 From: levzzz <86072227+levzzz5154@users.noreply.github.com> Date: Tue, 27 Oct 2026 04:57:27 +0500 Subject: [PATCH] Add the decorated pot's back-face culling regression test `DecoratedPotRenderer` submits every part with `RenderTypes.entitySolid`, whose pipeline culls back faces. The pot's `top` and `bottom` are flat boxes, so without that cull both sides of each plane are drawn and they z-fight: the pot renders wrong (kacpherek's #2099 draws the cull). The test renders a plain pot and checks that all of vanilla's 28 submitted quads are kept and that every one of them is marked for the cull, so the behaviour cannot silently regress. It fails without the cull. Co-Authored-By: minimax-m3.1-flash (Claude Code) --- .../horizon-client/src/block_entity_render.rs | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/crates/horizon-client/src/block_entity_render.rs b/crates/horizon-client/src/block_entity_render.rs index e8447ecf3..3e4e2790d 100644 --- a/crates/horizon-client/src/block_entity_render.rs +++ b/crates/horizon-client/src/block_entity_render.rs @@ -2118,4 +2118,70 @@ mod tests { assert_eq!(first_line("\u{6771}", 3.0, &advance), "\u{6771}"); assert_eq!(first_line("ab\ncd", 100.0, &advance), "ab"); } + /// `DecoratedPotRenderer` submits every part with `RenderTypes.entitySolid`, + /// whose pipeline culls back faces. The pot's `top` and `bottom` are flat + /// boxes, so without that cull both sides of each plane are drawn and they + /// z-fight: the pot renders wrong. + #[test] + fn the_decorated_pot_culls_its_back_faces() { + let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("../../.local/horizon-client") + .join(horizon_core::VANILLA_VERSION); + if !root.join("entity-models.json").exists() { + return; + } + let assets = crate::assets::Assets::load(&root).unwrap(); + let registry = assets.registry; + let renderer = BlockEntityRenderer::load(&root, ®istry).unwrap(); + let state = registry.default_state("minecraft:decorated_pot").unwrap(); + let sprites: HashMap = [ + "entity/decorated_pot/decorated_pot_base", + "entity/decorated_pot/decorated_pot_side", + ] + .into_iter() + .map(|name| { + ( + name.to_owned(), + Rect { + u0: 0.25, + v0: 0.125, + u1: 0.375, + v1: 0.25, + w: 16, + h: 16, + }, + ) + }) + .collect(); + let world = World::new(BlockStateId(0), 1); + let scene = Scene { + camera: DVec3::ZERO, + orientation: Quat::IDENTITY, + anim: &|_| BlockAnim::default(), + texts: None, + partial: 0.5, + game_time: 0, + max_y: 320, + world: &world, + sprites: &sprites, + nether: false, + lid: &|_| 0.0, + sign: &|_| None, + banner: &|_| Vec::new(), + skull: &|_| None, + glyph: &|_| (None, 0.0), + }; + let mut verts = Vec::new(); + renderer.render_block(&scene, [0; 3], state.0, Mat4::IDENTITY, 0xff, &mut verts); + // Vanilla submits 28 quads for a plain pot, and the cull keeps them all. + assert_eq!( + verts.len() / 4, + 28, + "the pot submits all of vanilla's quads" + ); + assert!( + verts.iter().all(|v| v.normal == CULL_BACK), + "entitySolid culls the pot's back faces" + ); + } }