From e7f5201c1f89b4ad7128f492bb16b8808e1f8d34 Mon Sep 17 00:00:00 2001 From: leifiyoo Date: Tue, 27 Oct 2026 15:52:23 +0100 Subject: [PATCH 1/2] Client: worn dyed leather armour shows its dye colour EquipmentLayerRenderer.getColorForLayer takes a dyeable layer's colour from the stack's minecraft:dyed_color and falls back to the asset's undyed colour. The player's own armour and LAN guests' armour, plus armour stands, used only the undyed colour, so dyed leather looked brown. Co-Authored-By: Claude Haiku 5.5 --- .../horizon-client/src/game/armor_stands.rs | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/crates/horizon-client/src/game/armor_stands.rs b/crates/horizon-client/src/game/armor_stands.rs index 4c0bd32e3..b1a4874b8 100644 --- a/crates/horizon-client/src/game/armor_stands.rs +++ b/crates/horizon-client/src/game/armor_stands.rs @@ -16,6 +16,19 @@ use horizon_core::{ }; use std::{collections::HashMap, path::PathBuf, sync::Arc}; +/// `EquipmentLayerRenderer.getColorForLayer` for a dyeable layer: the +/// stack's `minecraft:dyed_color` wins, else the asset's undyed colour, else +/// white. The result is in the renderer's byte order (R and B swapped). +fn layer_color(undyed: Option, stack: Option<&ItemStack>) -> u32 { + let dyed = stack + .and_then(|s| s.data()) + .and_then(|d| d.dyed_color) + .map(|c| c as u32 & 0xFF_FFFF); + dyed.or(undyed).map_or(0xFFFF_FFFF, |c| { + 0xFF00_0000 | (c & 0xFF) << 16 | (c & 0xFF00) | (c >> 16) & 0xFF + }) +} + /// Armor stand models and the humanoid layers of every equipment asset. pub(super) struct ArmorStandAssets { pub main: Option, @@ -179,9 +192,7 @@ impl Game<'_> { ) else { continue; }; - let color = undyed.map_or(0xFFFF_FFFF, |c| { - 0xFF00_0000 | (c & 0xFF) << 16 | (c & 0xFF00) | (c >> 16) & 0xFF - }); + let color = layer_color(*undyed, stack); out.push((part, [r.u0, r.v0, r.u1, r.v1], color)); // EquipmentLayerRenderer: the trim layer over the armour. if let Some(r) = stack @@ -695,9 +706,7 @@ impl Game<'_> { else { continue; }; - let color = undyed.map_or(0xFFFF_FFFF, |c| { - 0xFF00_0000 | (c & 0xFF) << 16 | (c & 0xFF00) | (c >> 16) & 0xFF - }); + let color = layer_color(*undyed, Some(stack)); // ArmorStandRenderer's HumanoidArmorLayer: the armour glint // when `stack.hasFoil()`, as on a living entity. let item_glint = self @@ -993,3 +1002,19 @@ mod burn_drop_tests { assert_eq!(drops, vec![kept]); } } +#[cfg(test)] +mod layer_color_tests { + use super::*; + #[test] + fn a_dyed_stack_overrides_the_undyed_leather_colour() { + let mut dyed = ItemStack::new("minecraft:leather_helmet", 1); + dyed.data_mut().dyed_color = Some(0x1E_90FF); + // Dyed blue, R and B swapped into the renderer's order, opaque. + assert_eq!(layer_color(Some(0xA06540), Some(&dyed)), 0xFFFF_901E); + // An undyed stack keeps the asset's brown. + let plain = ItemStack::new("minecraft:leather_helmet", 1); + assert_eq!(layer_color(Some(0xA06540), Some(&plain)), 0xFF40_65A0); + // No dye and no undyed colour: white. + assert_eq!(layer_color(None, Some(&plain)), 0xFFFF_FFFF); + } +} From 8057d27511a9df7d8b9f473af9054da012db6f2b Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 27 Oct 2026 22:26:12 +0100 Subject: [PATCH 2/2] Worn armour: only a dyeable layer takes the stack's dye getColorForLayer returns white for a layer without Dyeable, whatever dyed_color the stack has. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game/armor_stands.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/horizon-client/src/game/armor_stands.rs b/crates/horizon-client/src/game/armor_stands.rs index b1a4874b8..3cc889a59 100644 --- a/crates/horizon-client/src/game/armor_stands.rs +++ b/crates/horizon-client/src/game/armor_stands.rs @@ -16,15 +16,17 @@ use horizon_core::{ }; use std::{collections::HashMap, path::PathBuf, sync::Arc}; -/// `EquipmentLayerRenderer.getColorForLayer` for a dyeable layer: the -/// stack's `minecraft:dyed_color` wins, else the asset's undyed colour, else -/// white. The result is in the renderer's byte order (R and B swapped). +/// `EquipmentLayerRenderer.getColorForLayer`: a dyeable layer (one with a +/// colour when undyed) takes the stack's `minecraft:dyed_color`, else that +/// colour; any other layer stays white, dyed or not. The result is in the +/// renderer's byte order (R and B swapped). fn layer_color(undyed: Option, stack: Option<&ItemStack>) -> u32 { let dyed = stack .and_then(|s| s.data()) .and_then(|d| d.dyed_color) .map(|c| c as u32 & 0xFF_FFFF); - dyed.or(undyed).map_or(0xFFFF_FFFF, |c| { + undyed.map_or(0xFFFF_FFFF, |undyed| { + let c = dyed.unwrap_or(undyed); 0xFF00_0000 | (c & 0xFF) << 16 | (c & 0xFF00) | (c >> 16) & 0xFF }) } @@ -1016,5 +1018,7 @@ mod layer_color_tests { assert_eq!(layer_color(Some(0xA06540), Some(&plain)), 0xFF40_65A0); // No dye and no undyed colour: white. assert_eq!(layer_color(None, Some(&plain)), 0xFFFF_FFFF); + // A layer that isn't dyeable stays white even on a dyed stack. + assert_eq!(layer_color(None, Some(&dyed)), 0xFFFF_FFFF); } }