Items: glint enchanted armour on armour stands

ArmorStandRenderer draws worn armour through the same
HumanoidArmorLayer as a living entity, so its pieces should use the
armour glint when ItemStack.hasFoil() is true. The stand's equipment
loop now checks the stack's enchantment_glint_override component, then
the item's default override, then its enchantments component (vanilla's
Item.isFoil), and draws both the armour and its trim layer with overlay
13. The existing ARMOR_GLINT path supplies the model UV and samples
enchanted_glint_armor through ARMOR_ENTITY_GLINT_TEXTURING.

Co-Authored-By: ZCode <agent@zcode.dev>
This commit is contained in:
masa-masa-0314
2026-10-27 06:14:36 +08:00
parent 43e407562f
commit 66607c9eab
2 changed files with 29 additions and 2 deletions
+16 -2
View File
@@ -706,6 +706,20 @@ impl Game<'_> {
let color = undyed.map_or(0xFFFF_FFFF, |c| {
0xFF00_0000 | (c & 0xFF) << 16 | (c & 0xFF00) | (c >> 16) & 0xFF
});
// ArmorStandRenderer's HumanoidArmorLayer: the armour glint
// when `stack.hasFoil()`, as on a living entity.
let item_glint = self
.res
.items()
.enchantments
.props
.get(&stack.item)
.is_some_and(|p| p.glint);
let overlay = if stack.has_foil(item_glint) {
horizon_client::mobs::render::ARMOR_GLINT
} else {
0
};
let layer_poses = Poses::new(part);
horizon_client::mobs::render::draw(
part,
@@ -714,7 +728,7 @@ impl Game<'_> {
uv,
color,
packed,
0,
overlay,
out,
);
// EquipmentLayerRenderer: the trim layer over the armour.
@@ -729,7 +743,7 @@ impl Game<'_> {
trim,
0xFFFF_FFFF,
packed,
0,
overlay,
out,
);
}
+13
View File
@@ -198,6 +198,19 @@ impl ItemStack {
pub fn has_any_enchantments(&self) -> bool {
!self.enchantments().is_empty() || !self.stored_enchantments().is_empty()
}
/// `ItemStack.hasFoil`: an explicit `minecraft:enchantment_glint_override`
/// component wins, then the item's default override (`item_glint`), then a
/// non-empty `minecraft:enchantments` component (`Item.isFoil` is
/// `ItemStack.isEnchanted`; stored book enchantments do not count).
pub fn has_foil(&self, item_glint: bool) -> bool {
if let Some(Tag::Byte(flag)) = self
.data()
.and_then(|d| d.other("minecraft:enchantment_glint_override"))
{
return *flag != 0;
}
item_glint || !self.enchantments().is_empty()
}
pub fn repair_cost(&self) -> u32 {
self.data().map_or(0, |d| d.repair_cost)
}