diff --git a/crates/horizon-client/src/mobs.rs b/crates/horizon-client/src/mobs.rs index 9d2bcf4f3..389c6c7e0 100644 --- a/crates/horizon-client/src/mobs.rs +++ b/crates/horizon-client/src/mobs.rs @@ -1888,8 +1888,14 @@ impl Mob { /// the last-hurt-by bookkeeping goals read. /// The `armor` and `armor_toughness` modifiers of worn humanoid armour. pub fn worn_armor(&self) -> (f32, f32) { + // An equine keeps its horse armor in `extra.head`: the item's `armor` + // and `armor_toughness` modifiers of the body slot. if equine::is_equine(self.species()) { - return (0.0, 0.0); + return self + .extra + .head + .as_deref() + .map_or((0.0, 0.0), spawning::horse_armor_stats); } [ &self.extra.head, diff --git a/crates/horizon-client/src/mobs/spawning.rs b/crates/horizon-client/src/mobs/spawning.rs index 9f9fbe705..867869070 100644 --- a/crates/horizon-client/src/mobs/spawning.rs +++ b/crates/horizon-client/src/mobs/spawning.rs @@ -109,6 +109,19 @@ pub fn armor_stats(item: &str) -> (f32, f32) { }; (points[slot], toughness) } +/// The armour and toughness a horse armor item adds in the body slot +/// (`ArmorMaterial.createAttributes(ArmorType.BODY)`). +pub fn horse_armor_stats(item: &str) -> (f32, f32) { + match item.strip_prefix("minecraft:") { + Some("leather_horse_armor") => (3.0, 0.0), + Some("copper_horse_armor") => (4.0, 0.0), + Some("iron_horse_armor") => (5.0, 0.0), + Some("golden_horse_armor") => (7.0, 0.0), + Some("diamond_horse_armor") => (11.0, 2.0), + Some("netherite_horse_armor") => (19.0, 3.0), + _ => (0.0, 0.0), + } +} /// `Mob.populateDefaultEquipmentSlots`: sometimes a set of armour, from the /// head down, of one random material. fn populate_armor(m: &mut Mob, d: &LocalDifficulty) {