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 1/3] 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" + ); + } } From 7250944a7c79b8c2371fafeb7714b9841ddf3e59 Mon Sep 17 00:00:00 2001 From: levzzz <86072227+levzzz5154@users.noreply.github.com> Date: Tue, 27 Oct 2026 05:06:20 +0500 Subject: [PATCH 2/3] Test the decorated pot item's back-face culling too The pot in the hand and dropped on the ground is drawn by the same `DecoratedPotRenderer` model, through the item path, so its quads carry the cull as well. The test fails without it. Co-Authored-By: minimax-m3.1-flash (Claude Code) --- .../horizon-client/src/item_render/special.rs | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/crates/horizon-client/src/item_render/special.rs b/crates/horizon-client/src/item_render/special.rs index 8a54f49bb..f93a4c6d9 100644 --- a/crates/horizon-client/src/item_render/special.rs +++ b/crates/horizon-client/src/item_render/special.rs @@ -686,4 +686,51 @@ mod tests { ); } } + /// `DecoratedPotRenderer` draws every part with `RenderTypes.entitySolid`, + /// whose pipeline culls back faces: the pot's flat `top` and `bottom` + /// planes would otherwise show both sides and z-fight in the hand too. + #[test] + fn the_decorated_pot_item_culls_its_back_faces() { + let root = Path::new(env!("CARGO_MANIFEST_DIR")) + .join("../../.local/horizon-client") + .join(horizon_core::VANILLA_VERSION); + if !root.join("entity-models.json").exists() { + return; + } + let renderer = ItemRenderer::load(&root).unwrap(); + let sprite = Rect { + u0: 0.25, + v0: 0.125, + u1: 0.375, + v1: 0.25, + w: 16, + h: 16, + }; + let sprites: HashMap = [ + "entity/decorated_pot/decorated_pot_base", + "entity/decorated_pot/decorated_pot_side", + ] + .into_iter() + .map(|name| (name.to_owned(), sprite)) + .collect(); + let model = SpecialModel { + kind: SpecialKind::DecoratedPot, + }; + let mut quads: Vec = Vec::new(); + submit( + &renderer, + &model, + &Value::Null, + false, + Mat4::IDENTITY, + &sprites, + &super::super::NoHost, + &mut quads, + ); + assert!(!quads.is_empty(), "the pot item draws its parts"); + assert!( + quads.iter().all(|q| q.cull_back), + "entitySolid culls the pot's back faces" + ); + } } From b7749dd0d2b87b29ca01bbf40990cbc467bc34e8 Mon Sep 17 00:00:00 2001 From: levzzz <86072227+levzzz5154@users.noreply.github.com> Date: Tue, 27 Oct 2026 09:38:03 +0500 Subject: [PATCH 3/3] Fix a needless borrow in the decorated pot's test Clippy's needless_borrow: the registry is already a reference, so the extra & is dereferenced right away. Co-Authored-By: minimax-m3.1-flash (Claude Code) --- crates/horizon-client/src/block_entity_render.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/horizon-client/src/block_entity_render.rs b/crates/horizon-client/src/block_entity_render.rs index 3e4e2790d..c7ae80b22 100644 --- a/crates/horizon-client/src/block_entity_render.rs +++ b/crates/horizon-client/src/block_entity_render.rs @@ -2132,7 +2132,7 @@ mod tests { } let assets = crate::assets::Assets::load(&root).unwrap(); let registry = assets.registry; - let renderer = BlockEntityRenderer::load(&root, ®istry).unwrap(); + let renderer = BlockEntityRenderer::load(&root, registry).unwrap(); let state = registry.default_state("minecraft:decorated_pot").unwrap(); let sprites: HashMap = [ "entity/decorated_pot/decorated_pot_base",