From 2886b8f9badc4cb7e4e7a775a84ef83e961751b9 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 19:39:31 +0100 Subject: [PATCH] Horse armor reduces the damage a horse takes --- crates/horizon-client/src/mobs.rs | 8 +++++++- crates/horizon-client/src/mobs/spawning.rs | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/crates/horizon-client/src/mobs.rs b/crates/horizon-client/src/mobs.rs index 6b1e16f5c..e64d81f39 100644 --- a/crates/horizon-client/src/mobs.rs +++ b/crates/horizon-client/src/mobs.rs @@ -1694,8 +1694,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 93e3fe119..50d311db3 100644 --- a/crates/horizon-client/src/mobs/spawning.rs +++ b/crates/horizon-client/src/mobs/spawning.rs @@ -96,6 +96,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) {