From 4218a496b2756bb9f9261bb4025b6f1a9711c582 Mon Sep 17 00:00:00 2001 From: Cosmic <84875247+Online5277@users.noreply.github.com> Date: Fri, 16 Oct 2026 14:40:28 -0400 Subject: [PATCH 1/4] Preserve ominous banner components through placement and drops --- crates/horizon-client/src/containers.rs | 2 + crates/horizon-client/src/game/spill.rs | 74 +++++++++++++++++++++++-- crates/horizon-client/src/save.rs | 12 +++- 3 files changed, 81 insertions(+), 7 deletions(-) diff --git a/crates/horizon-client/src/containers.rs b/crates/horizon-client/src/containers.rs index 46e73f067..9cdac1463 100644 --- a/crates/horizon-client/src/containers.rs +++ b/crates/horizon-client/src/containers.rs @@ -132,6 +132,8 @@ impl Crafter { pub struct Banner { pub layers: Vec, pub name: Option, + /// Components not consumed by BannerBlockEntity's implicit fields. + pub components: horizon_world::nbt::Compound, } /// `CreakingHeartBlockEntity` (the logic is in `game/creaking.rs`). #[derive(Clone, Debug, Default)] diff --git a/crates/horizon-client/src/game/spill.rs b/crates/horizon-client/src/game/spill.rs index ac508dfb8..5f10622f5 100644 --- a/crates/horizon-client/src/game/spill.rs +++ b/crates/horizon-client/src/game/spill.rs @@ -6,6 +6,7 @@ use super::{Game, GameLevel, Screen, dispenser::new_item_motion, storage::is_shulker_box}; use horizon_client::{ containers::{Banner, BlockEntity}, + item_data, items::ItemStack, }; use horizon_core::position::BlockPos; @@ -15,6 +16,7 @@ use horizon_world::{ LevelEvent, removal::{self, PreRemove}, }, + nbt::{JavaString, Tag}, registry::BlockStateId, }; use std::collections::HashMap; @@ -80,14 +82,37 @@ impl Pending { stack.data_mut().pot_decorations = Some(Box::new(sides)); } if stack.item.ends_with("_banner") - && let Some(Banner { layers, name }) = self.banner.remove(&pos) + && let Some(Banner { + layers, + name, + components, + }) = self.banner.remove(&pos) { - let data = stack.data_mut(); - data.banner_patterns = layers; - if name.is_some() { - data.custom_name = name; + let mut patch = match item_data::encode_components(stack) { + Some(Tag::Compound(c)) => c, + _ => Default::default(), + }; + // The remaining components in the banner loot table's copy_components. + for key in [ + "minecraft:item_name", + "minecraft:rarity", + "minecraft:tooltip_display", + ] { + if let Some(value) = components.get(&JavaString::from(key)) { + patch.insert(key.into(), value.clone()); + } } - stack.tidy(); + patch.insert( + "minecraft:banner_patterns".into(), + horizon_client::banner::layers_to_nbt(&layers), + ); + if let Some(name) = name { + patch.insert( + "minecraft:custom_name".into(), + Tag::String(name.as_str().into()), + ); + } + (stack.damage, stack.extra) = item_data::decode_components(Some(&Tag::Compound(patch))); } } /// Remember a decorated pot's sherds from its saved block entity. @@ -553,3 +578,40 @@ impl Game<'_> { } } } + +#[cfg(test)] +mod tests { + use super::*; + use horizon_client::{block_entity_item, item_data, mobs::raider, save}; + use horizon_world::nbt::Tag; + + #[test] + fn ominous_banner_survives_placement_save_and_drop() { + let original = raider::ominous_banner(); + let Tag::Compound(components) = item_data::encode_components(&original).unwrap() else { + panic!("banner components"); + }; + for block in ["minecraft:white_banner", "minecraft:white_wall_banner"] { + let pos = (1, 64, 2); + let fresh = BlockEntity::for_block(block).unwrap(); + let fresh = save::encode_block_entity(pos, &fresh, block); + let placed = block_entity_item::place(&fresh, &components, false); + let (_, placed) = save::decode_block_entity(&placed).unwrap(); + let saved = save::encode_block_entity(pos, &placed, block); + let (_, loaded) = save::decode_block_entity(&saved).unwrap(); + let BlockEntity::Banner(banner) = &loaded else { + panic!("placed banner"); + }; + assert_eq!(banner.layers.len(), item_data::OMINOUS_LAYERS.len()); + let mut pending = Pending::default(); + pending.record([pos.0, pos.1, pos.2], &loaded, block, None); + let mut dropped = ItemStack::new("minecraft:white_banner", 1); + pending.attach([pos.0, pos.1, pos.2], &mut dropped); + assert!(dropped.data().unwrap().ominous_banner); + assert_eq!( + item_data::encode_components(&dropped), + Some(Tag::Compound(components.clone())) + ); + } + } +} diff --git a/crates/horizon-client/src/save.rs b/crates/horizon-client/src/save.rs index a3ee81912..61317c8aa 100644 --- a/crates/horizon-client/src/save.rs +++ b/crates/horizon-client/src/save.rs @@ -449,13 +449,17 @@ pub fn encode_block_entity( block: &str, ) -> Tag { use crate::containers::BlockEntity; + let components = match e { + BlockEntity::Banner(b) => b.components.clone(), + _ => Compound::new(), + }; let mut entries = vec![ ("id", string(&block_entity_id(e, block))), ("x", Tag::Int(p.0)), ("y", Tag::Int(p.1)), ("z", Tag::Int(p.2)), ("keepPacked", Tag::Byte(0)), - ("components", Tag::Compound(Compound::new())), + ("components", Tag::Compound(components)), ]; match e { BlockEntity::Chest(items) => entries.push(("Items", encode_items(items))), @@ -583,6 +587,10 @@ pub fn decode_block_entity(tag: &Tag) -> Option<((i32, i32, i32), crate::contain BlockEntity::Banner(crate::containers::Banner { layers: crate::banner::layers_from_nbt(tag.get("patterns")), name: text(tag.get("CustomName")), + components: match tag.get("components") { + Some(Tag::Compound(c)) => c.clone(), + _ => Compound::new(), + }, }), )); } @@ -2984,6 +2992,7 @@ mod tests { let banner = crate::containers::Banner { layers: vec![crate::banner::BannerLayer::new("minecraft:creeper", "lime")], name: Some("Flag".into()), + components: [("minecraft:rarity".into(), string("uncommon"))].into(), }; let tag = encode_block_entity( (1, 2, 3), @@ -2997,6 +3006,7 @@ mod tests { }; assert_eq!(back.layers, banner.layers); assert_eq!(back.name, banner.name); + assert_eq!(back.components, banner.components); } use super::*; From 8f86098a02ffb3101fa35bcf1cff6a14b8bb3582 Mon Sep 17 00:00:00 2001 From: Cosmic <84875247+Online5277@users.noreply.github.com> Date: Fri, 16 Oct 2026 15:07:19 -0400 Subject: [PATCH 2/4] Show ominous banner names and rarity in HUD and Creative tooltips --- crates/horizon-client/src/game.rs | 10 +++--- crates/horizon-client/src/game/spill.rs | 8 +++++ crates/horizon-client/src/game/stations.rs | 16 +++------ crates/horizon-client/src/game/titles.rs | 21 ++++------- crates/horizon-client/src/item_tooltip.rs | 42 ++++++++++++++++++++++ 5 files changed, 66 insertions(+), 31 deletions(-) diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 7072abeb5..c65c00d25 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -7999,7 +7999,7 @@ impl Game<'_> { self.creative_screen.search_focused.elapsed().as_millis(), ); } - let mut hovered: Option = None; + let mut hovered: Option = None; if tab.inventory { self.draw_player_preview( batch, @@ -8049,7 +8049,7 @@ impl Game<'_> { && self.cursor.1 < y + 16.0 { batch.fill(&self.res.atlas, x, y, 16.0, 16.0, rgba(255, 255, 255, 128)); - hovered = Some(stack.item.to_string()); + hovered = Some(stack.clone()); } } } @@ -8064,7 +8064,7 @@ impl Game<'_> { && self.cursor.1 >= y && self.cursor.1 < y + 16.0 { - hovered = Some(stack.item.to_string()); + hovered = Some(stack); } } let scrollable = self.creative_screen.rows(&self.res.names) > 5; @@ -8100,8 +8100,8 @@ impl Game<'_> { } else if self.carried.is_none() && let Some(item) = hovered { - let name = self.res.names.item(&item); - self.tooltip(batch, &name, self.cursor.0, self.cursor.1); + let lines = self.stack_tooltip(&item); + self.draw_tooltip_lines(batch, &lines, self.cursor.0, self.cursor.1); } self.draw_inventory_effects(batch, (ox, oy), Creative::WIDTH as i32); } diff --git a/crates/horizon-client/src/game/spill.rs b/crates/horizon-client/src/game/spill.rs index 5f10622f5..b64bcb9d7 100644 --- a/crates/horizon-client/src/game/spill.rs +++ b/crates/horizon-client/src/game/spill.rs @@ -608,6 +608,14 @@ mod tests { let mut dropped = ItemStack::new("minecraft:white_banner", 1); pending.attach([pos.0, pos.1, pos.2], &mut dropped); assert!(dropped.data().unwrap().ominous_banner); + assert_eq!( + horizon_client::item_tooltip::name_line(&dropped, &|_| None), + "Ominous Banner" + ); + assert_eq!( + horizon_client::item_tooltip::rarity(&dropped, "common"), + "uncommon" + ); assert_eq!( item_data::encode_components(&dropped), Some(Tag::Compound(components.clone())) diff --git a/crates/horizon-client/src/game/stations.rs b/crates/horizon-client/src/game/stations.rs index d8a5d1416..1c253757d 100644 --- a/crates/horizon-client/src/game/stations.rs +++ b/crates/horizon-client/src/game/stations.rs @@ -1860,18 +1860,10 @@ impl Game<'_> { pub(super) fn stack_tooltip(&self, stack: &ItemStack) -> Vec<(String, u32)> { let e: &Enchantments = &self.res.stations.enchantments; let props = e.props(&stack.item); - let mut rarity = props.map_or("common", |p| p.rarity.as_str()); - // The ominous banner's rarity component. - if stack.data().is_some_and(|d| d.ominous_banner) { - rarity = "uncommon"; - } - if !stack.enchantments().is_empty() { - rarity = match rarity { - "common" | "uncommon" => "rare", - "rare" => "epic", - r => r, - }; - } + let rarity = horizon_client::item_tooltip::rarity( + stack, + props.map_or("common", |p| p.rarity.as_str()), + ); let color = match rarity { "uncommon" => rgba(255, 255, 85, 255), "rare" => rgba(85, 255, 255, 255), diff --git a/crates/horizon-client/src/game/titles.rs b/crates/horizon-client/src/game/titles.rs index 89e50c0d0..f0de6ad9e 100644 --- a/crates/horizon-client/src/game/titles.rs +++ b/crates/horizon-client/src/game/titles.rs @@ -6,6 +6,7 @@ use horizon_client::{ hud::HudBatch, hud_layout, hud_overlays::HeldName, + item_tooltip, text::{self, Text}, }; @@ -24,22 +25,14 @@ impl Game<'_> { fn held_name(&self) -> Option { let stack = self.inventory.get(self.selected)?.as_ref()?; let custom = stack.custom_name(); - // ItemStack.getRarity: enchanting raises common and uncommon to rare - // and rare to epic. - let mut rarity = self.item_rarity(&stack.item); - if !stack.enchantments().is_empty() { - rarity = match rarity.as_str() { - "common" | "uncommon" => "rare".into(), - "rare" => "epic".into(), - _ => rarity, - }; - } + let default_rarity = self.item_rarity(&stack.item); + let rarity = item_tooltip::rarity(stack, &default_rarity); Some(HeldName { item: stack.item.to_string(), - hover_name: Text::literal( - custom.map_or_else(|| self.res.names.item(&stack.item), str::to_owned), - ), - rarity_color: match rarity.as_str() { + hover_name: Text::literal(item_tooltip::name_line(stack, &|key| { + self.res.names.get(key).map(str::to_owned) + })), + rarity_color: match rarity { "uncommon" => text::YELLOW, "rare" => text::AQUA, "epic" => text::LIGHT_PURPLE, diff --git a/crates/horizon-client/src/item_tooltip.rs b/crates/horizon-client/src/item_tooltip.rs index cd827d411..a039edfc5 100644 --- a/crates/horizon-client/src/item_tooltip.rs +++ b/crates/horizon-client/src/item_tooltip.rs @@ -102,6 +102,10 @@ pub fn name_line(stack: &ItemStack, translate: &dyn Fn(&str) -> Option) if let Some(name) = stack.custom_name() { return name.to_owned(); } + if stack.data().is_some_and(|d| d.ominous_banner) { + return translate("block.minecraft.ominous_banner") + .unwrap_or_else(|| "Ominous Banner".to_owned()); + } let key = if is_potion_item(&stack.item) { Some(crate::brewing::potion_name_key(&stack.item, stack.potion())) } else if let Some(pattern) = path.strip_suffix("_armor_trim_smithing_template") { @@ -120,6 +124,24 @@ pub fn name_line(stack: &ItemStack, translate: &dyn Fn(&str) -> Option) .unwrap_or_else(|| path.replace('_', " ")) } +/// ItemStack.getRarity: the ominous banner override, then the enchantment upgrade. +pub fn rarity<'a>(stack: &ItemStack, default: &'a str) -> &'a str { + let rarity = if stack.data().is_some_and(|d| d.ominous_banner) { + "uncommon" + } else { + default + }; + if stack.enchantments().is_empty() { + rarity + } else { + match rarity { + "common" | "uncommon" => "rare", + "rare" => "epic", + r => r, + } + } +} + /// The lines of `stack` below its name that its components give, in /// `ItemStack.addDetailsToTooltip` order. pub fn detail_lines( @@ -292,6 +314,26 @@ pub fn lines( mod tests { use super::*; + #[test] + fn ominous_banner_name_and_rarity_use_the_stack() { + let translate = |key: &str| match key { + "block.minecraft.ominous_banner" => Some("Ominous Banner".to_owned()), + "block.minecraft.white_banner" => Some("White Banner".to_owned()), + _ => None, + }; + let mut banner = crate::mobs::raider::ominous_banner(); + assert_eq!(name_line(&banner, &translate), "Ominous Banner"); + assert_eq!(name_line(&banner, &|_| None), "Ominous Banner"); + assert_eq!(rarity(&banner, "common"), "uncommon"); + banner.data_mut().custom_name = Some("Captain's Standard".into()); + assert_eq!(name_line(&banner, &translate), "Captain's Standard"); + banner.enchant("minecraft:unbreaking", 1); + assert_eq!(rarity(&banner, "common"), "rare"); + let plain = ItemStack::new("minecraft:white_banner", 1); + assert_eq!(name_line(&plain, &translate), "White Banner"); + assert_eq!(rarity(&plain, "common"), "common"); + } + #[test] fn container_lines_list_five_stacks_then_how_many_more() { let mut chest = ItemStack::new("minecraft:chest", 1); From 86ccd5d299b2752aca6c29cafd3d88601af9bf66 Mon Sep 17 00:00:00 2001 From: Cosmic <84875247+Online5277@users.noreply.github.com> Date: Fri, 16 Oct 2026 16:40:29 -0400 Subject: [PATCH 3/4] Render banner breaking cracks and oak-plank particles --- .../horizon-client/src/block_entity_render.rs | 155 +++++++++++++++++- crates/horizon-client/src/breaking.rs | 48 ++++++ crates/horizon-client/src/game.rs | 24 ++- crates/horizon-client/src/models/catalog.rs | 7 + 4 files changed, 227 insertions(+), 7 deletions(-) diff --git a/crates/horizon-client/src/block_entity_render.rs b/crates/horizon-client/src/block_entity_render.rs index 9ffd888a1..85107c1cb 100644 --- a/crates/horizon-client/src/block_entity_render.rs +++ b/crates/horizon-client/src/block_entity_render.rs @@ -876,7 +876,7 @@ impl BlockEntityRenderer { .as_vec3(); let base = Mat4::from_translation(origin); let packed = scene.world.light(pos[0], pos[1], pos[2]); - self.render_one(scene, *pos, kind, base, packed, lights, out); + self.render_one(scene, *pos, kind, base, packed, lights, false, out); } } /// One block entity at `pos` drawn under `base` with the given packed light @@ -892,12 +892,39 @@ impl BlockEntityRenderer { ) { let kind = self.kind(state); let lights = diffuse_lights(scene.nether); - self.render_one(scene, pos, kind, base, packed, lights, out); + self.render_one(scene, pos, kind, base, packed, lights, false, out); } /// Whether this block state has a block-entity renderer here. pub fn renders(&self, state: u32) -> bool { !matches!(self.kind(state), Kind::None) } + /// BannerRenderer submits the support and animated flag once for crumbling. + pub fn render_banner_breaking( + &self, + scene: &Scene, + pos: [i32; 3], + state: u32, + out: &mut Vec, + ) { + if !matches!(self.kind(state), Kind::Banner { .. }) { + return; + } + let origin = (DVec3::new(f64::from(pos[0]), f64::from(pos[1]), f64::from(pos[2])) + - scene.camera) + .as_vec3(); + let start = out.len(); + self.render_one( + scene, + pos, + self.kind(state), + Mat4::from_translation(origin), + 0xff, + diffuse_lights(scene.nether), + true, + out, + ); + crate::breaking::entity_geometry(&mut out[start..], origin); + } /// `ChestRenderer.extractRenderState`'s openness for the chest of `state` /// at `pos`: `ChestBlock.combine` (`DoubleBlockCombiner.combineWithNeigbour`) /// pairs a double half with its neighbour only when that is the same @@ -970,7 +997,7 @@ impl BlockEntityRenderer { let kind = self.kind(state); if !matches!(kind, Kind::None) { let lights = diffuse_lights(scene.nether); - self.render_one(scene, [i32::MAX; 3], kind, base, packed, lights, out); + self.render_one(scene, [i32::MAX; 3], kind, base, packed, lights, false, out); } } #[allow(clippy::too_many_arguments)] @@ -982,11 +1009,24 @@ impl BlockEntityRenderer { base: Mat4, packed: u8, lights: (Vec3, Vec3), + crumbling: bool, out: &mut Vec, ) { let sprite = |name: &str| scene.sprites.get(name).copied(); let paint = |name: &str, tint: u32, packed: u8| { - sprite(name).map(|s| Paint { + let rect = if crumbling { + Some(Rect { + u0: 0.0, + v0: 0.0, + u1: 1.0, + v1: 1.0, + w: 16, + h: 16, + }) + } else { + sprite(name) + }; + rect.map(|s| Paint { sprite: s, tint, light: vertex_light(packed), @@ -1145,6 +1185,10 @@ impl BlockEntityRenderer { draw_part(main, "root", m, &none, paint, out); draw_part(flag, "root", m, &wave, paint, out); } + // Pattern passes must not multiply the crumbling decal. + if crumbling { + return; + } // BannerRenderer.submitPatterns: the base pattern layer in the dye colour, // then up to 16 pattern layers in order. if let Some(paint) = paint("entity/banner/base", *color, packed) { @@ -1673,6 +1717,109 @@ fn portal_cube(m: Mat4, faces: &[Direction], layer: u32, out: &mut Vec) #[cfg(test)] mod tests { use super::*; + #[test] + #[ignore = "requires prepared models/textures in HORIZON_TEST_RESOURCES"] + fn banner_particle_and_breaking_use_exported_models() -> crate::Result<()> { + use crate::{models::catalog::StateModels, sprites::Sprites}; + use horizon_world::{DATA_VERSION, chunk::BlockState, nbt::Tag}; + let root = std::path::PathBuf::from( + std::env::var_os("HORIZON_TEST_RESOURCES").expect("HORIZON_TEST_RESOURCES"), + ); + let names = ["white_banner", "white_wall_banner"]; + let mut facts: std::collections::BTreeMap = + serde_json::from_slice(&std::fs::read(root.join("model-states.json"))?)?; + let states = names.map(|name| { + let name = format!("minecraft:{name}"); + let first = facts[&name]["states"][0].clone(); + facts.get_mut(&name).unwrap()["states"] = serde_json::json!([first.clone()]); + BlockState { + name, + properties: serde_json::from_value(first).unwrap(), + } + .to_nbt() + }); + let registry = BlockRegistry::from_nbt(&Tag::compound([ + ("DataVersion", Tag::Int(DATA_VERSION)), + ("states", Tag::List(states.into())), + ( + "defaults", + Tag::compound([ + ("minecraft:white_banner", Tag::Int(0)), + ("minecraft:white_wall_banner", Tag::Int(1)), + ]), + ), + ]))?; + let mut sprites = Sprites::default(); + let catalog = StateModels::from_facts(&root, ®istry, &names, &mut sprites, &facts)?; + for id in 0..2 { + let models = catalog.collect( + BlockStateId(id), + horizon_core::position::BlockPos::default(), + )?; + assert!(models.iter().all(|(_, model)| model.faces.is_empty())); + assert_eq!( + models[0].1.particle, + Some(sprites.layers["minecraft:block/oak_planks"]) + ); + } + let all: Value = serde_json::from_slice(&std::fs::read(root.join("entity-models.json"))?)?; + let renderer = BlockEntityRenderer::new( + MODELS + .iter() + .filter_map(|(key, layer)| all.get(*layer).map(|v| (*key, ModelPart::parse(v)))) + .collect(), + ®istry, + ); + let world = World::new(BlockStateId(0), 1); + let base_sprites = HashMap::from([( + "entity/banner/banner_base".to_owned(), + Rect { + u0: 0.0, + v0: 0.0, + u1: 1.0, + v1: 1.0, + w: 16, + h: 16, + }, + )]); + let mut 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: &base_sprites, + nether: false, + lid: &|_| 0.0, + sign: &|_| None, + banner: &|_| Vec::new(), + glyph: &|_| (None, 0.0), + }; + for state in 0..2 { + let mut base = Vec::new(); + renderer.render_block(&scene, [0; 3], state, Mat4::IDENTITY, 0xff, &mut base); + let mut cracks = Vec::new(); + renderer.render_banner_breaking(&scene, [0; 3], state, &mut cracks); + assert!(!cracks.is_empty()); + assert_eq!( + base.iter().map(|v| v.pos).collect::>(), + cracks.iter().map(|v| v.pos).collect::>() + ); + assert!(cracks.iter().all(|v| v.layer == 11 + && v.color == u32::MAX + && v.uv.iter().all(|u| u.is_finite()))); + scene.game_time = 20; + let mut animated = Vec::new(); + renderer.render_banner_breaking(&scene, [0; 3], state, &mut animated); + assert!(cracks.iter().zip(&animated).any(|(a, b)| a.pos != b.pos)); + scene.game_time = 0; + } + Ok(()) + } + #[test] fn classifies_vanilla_block_names() { let props = |pairs: &'static [(&'static str, &'static str)]| { diff --git a/crates/horizon-client/src/breaking.rs b/crates/horizon-client/src/breaking.rs index 9dc948ae3..c7ee19206 100644 --- a/crates/horizon-client/src/breaking.rs +++ b/crates/horizon-client/src/breaking.rs @@ -41,6 +41,35 @@ pub fn geometry(model: &BakedModel, origin: glam::Vec3, translucent: bool, out: } } +/// Project a block entity's transformed quads onto the same destroy-stage pass. +pub fn entity_geometry(vertices: &mut [Vertex], origin: glam::Vec3) { + for quad in vertices.as_chunks_mut::<4>().0 { + let positions = [0, 1, 2].map(|i| glam::Vec3::from(quad[i].pos)); + let normal = (positions[1] - positions[0]).cross(positions[2] - positions[0]); + let mut facing = Direction::North; + let mut best = f32::from_bits(1); + for (direction, dot) in [ + (Direction::Down, -normal.y), + (Direction::Up, normal.y), + (Direction::North, -normal.z), + (Direction::South, normal.z), + (Direction::West, -normal.x), + (Direction::East, normal.x), + ] { + if dot > best { + facing = direction; + best = dot; + } + } + for vertex in quad { + vertex.uv = decal_uv((glam::Vec3::from(vertex.pos) - origin).to_array(), facing); + vertex.layer = 11; + vertex.color = 0xffff_ffff; + vertex.light = 240 | (240 << 8); + } + } +} + #[cfg(test)] mod tests { use super::*; @@ -49,6 +78,7 @@ mod tests { fn slab_top() -> BakedModel { BakedModel { ambient_occlusion: true, + particle: None, cube: None, faces: vec![BakedFace { layer: 0, @@ -86,6 +116,24 @@ mod tests { assert_eq!(v.color, 0xffff_ffff); } } + #[test] + fn entity_overlay_uses_block_local_projected_uvs() { + let origin = glam::Vec3::new(12.0, -3.0, 8.0); + let mut expected = Vec::new(); + geometry(&slab_top(), origin, false, &mut expected); + let mut actual = expected.clone(); + for vertex in &mut actual { + vertex.uv = [0.0; 2]; + vertex.layer = 0; + vertex.color = 0; + } + entity_geometry(&mut actual, origin); + assert_eq!( + bytemuck::cast_slice::<_, u8>(&actual), + bytemuck::cast_slice::<_, u8>(&expected) + ); + } + #[test] fn small_faces_use_projected_not_stretched_uvs() { let a = decal_uv([0.0, 0.0, 0.0], Direction::North); diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index c65c00d25..21f59af94 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -1377,9 +1377,13 @@ impl Game<'_> { .iter() .flat_map(|(_, m)| m.faces.iter()) .find(|f| f.quad.facing == horizon_assets::model::Direction::Up) - .or_else(|| models.iter().flat_map(|(_, m)| m.faces.iter()).next())?; - let name = self.res.layer_names.get(&face.layer)?.clone(); - let tint = if face.quad.tint_index >= 0 { + .or_else(|| models.iter().flat_map(|(_, m)| m.faces.iter()).next()); + // Entity-rendered blocks may have a particle texture without any faces. + let layer = face + .map(|face| face.layer) + .or_else(|| models.iter().find_map(|(_, model)| model.particle))?; + let name = self.res.layer_names.get(&layer)?.clone(); + let tint = if face.is_some_and(|face| face.quad.tint_index >= 0) { let n = &self.res.facts.get(state).name; if n.contains("leaves") || n.contains("vine") { 0x48B518 @@ -5515,6 +5519,20 @@ impl Game<'_> { .block_entity_render .render(&scene, visible, &mut out); } + if let Some(mining) = &self.mining + && mining.progress > 0.0 + && self.res.atlas.sprites.contains_key(&format!( + "block/destroy_stage_{}", + ((mining.progress * 10.0) as u32).min(9) + )) + { + let state = self + .world + .block(mining.pos[0], mining.pos[1], mining.pos[2]); + self.res + .block_entity_render + .render_banner_breaking(&scene, mining.pos, state.0, &mut out); + } } // Experience orbs (ExperienceOrbRenderer): pulsing billboards from a 4x4 icon sheet. if let Some(r) = self diff --git a/crates/horizon-client/src/models/catalog.rs b/crates/horizon-client/src/models/catalog.rs index 59a885821..abb9e6c50 100644 --- a/crates/horizon-client/src/models/catalog.rs +++ b/crates/horizon-client/src/models/catalog.rs @@ -34,6 +34,8 @@ pub struct BakedFace { } pub struct BakedModel { pub ambient_occlusion: bool, + /// The model's particle slot also exists for models without block faces. + pub particle: Option, pub faces: Vec, pub cube: Option<[super::cube::CubeStyle; 6]>, } @@ -188,6 +190,10 @@ impl StateModels { let mut baked = BTreeMap::new(); for (name, turns, lock) in variants { let model = library.resolve(&name)?; + let particle = model + .material("particle")? + .map(|material| sprites.insert(root, &material.sprite)) + .transpose()?; let faces: Vec = bake_block_model(&model, BlockModelTransform::new(turns, lock))? .into_iter() @@ -207,6 +213,7 @@ impl StateModels { (name, turns, lock), BakedModel { ambient_occlusion: model.ambient_occlusion, + particle, faces, cube, }, From 53955abf99941128c2c263cd046deb0a92958957 Mon Sep 17 00:00:00 2001 From: Cosmic <84875247+Online5277@users.noreply.github.com> Date: Fri, 16 Oct 2026 16:56:14 -0400 Subject: [PATCH 4/4] Hide ominous banner pattern descriptions in tooltips --- crates/horizon-client/src/banner.rs | 26 ++++++++++++++++++++++ crates/horizon-client/src/game/spill.rs | 1 + crates/horizon-client/src/game/stations.rs | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/crates/horizon-client/src/banner.rs b/crates/horizon-client/src/banner.rs index d2bc33fba..861294722 100644 --- a/crates/horizon-client/src/banner.rs +++ b/crates/horizon-client/src/banner.rs @@ -199,6 +199,14 @@ pub fn dye_rgb(name: &str) -> u32 { pub fn layers(stack: &ItemStack) -> &[BannerLayer] { stack.data().map_or(&[], |d| &d.banner_patterns) } +/// The ominous banner's component patch hides its pattern tooltip. +pub fn tooltip_layers(stack: &ItemStack) -> &[BannerLayer] { + if stack.data().is_some_and(|d| d.ominous_banner) { + &[] + } else { + layers(stack) + } +} /// `LoomMenu.setupResultSlot`: one banner with the pattern added in the dye colour. pub fn loom_result(banner: &ItemStack, dye: &str, pattern: &str) -> ItemStack { let mut result = ItemStack { @@ -302,6 +310,24 @@ mod tests { } assert!(has_max_layers(&banner)); } + #[test] + fn ominous_banner_hides_tooltip_layers_but_keeps_its_patterns() { + let mut banner = crate::mobs::raider::ominous_banner(); + (banner.damage, banner.extra) = crate::item_data::decode_components( + crate::item_data::encode_components(&banner).as_ref(), + ); + assert_eq!( + layers(&banner).len(), + crate::item_data::OMINOUS_LAYERS.len() + ); + assert!(tooltip_layers(&banner).is_empty()); + banner.data_mut().custom_name = Some("Captain's Standard".into()); + assert!(tooltip_layers(&banner).is_empty()); + banner.data_mut().ominous_banner = false; + assert_eq!(tooltip_layers(&banner), layers(&banner)); + assert!(!tooltip_layers(&banner).is_empty()); + } + #[test] fn layers_round_trip_through_nbt() { let l = vec![ diff --git a/crates/horizon-client/src/game/spill.rs b/crates/horizon-client/src/game/spill.rs index b64bcb9d7..20dcdf0de 100644 --- a/crates/horizon-client/src/game/spill.rs +++ b/crates/horizon-client/src/game/spill.rs @@ -608,6 +608,7 @@ mod tests { let mut dropped = ItemStack::new("minecraft:white_banner", 1); pending.attach([pos.0, pos.1, pos.2], &mut dropped); assert!(dropped.data().unwrap().ominous_banner); + assert!(horizon_client::banner::tooltip_layers(&dropped).is_empty()); assert_eq!( horizon_client::item_tooltip::name_line(&dropped, &|_| None), "Ominous Banner" diff --git a/crates/horizon-client/src/game/stations.rs b/crates/horizon-client/src/game/stations.rs index 1c253757d..5e8952901 100644 --- a/crates/horizon-client/src/game/stations.rs +++ b/crates/horizon-client/src/game/stations.rs @@ -1944,7 +1944,7 @@ impl Game<'_> { )); } // BannerPatternLayers.addToTooltip: up to six layer names. - for layer in horizon_client::banner::layers(stack).iter().take(6) { + for layer in horizon_client::banner::tooltip_layers(stack).iter().take(6) { let key = self.res.stations.banners.layer_key(layer); lines.push((self.translate(&key, &key), rgba(170, 170, 170, 255))); }