Merge pull request #2395 from kacpherek/fix/horse-armor-protects

🤖 Agent: Proven in union R1 (branch union/cg19-r1, main + 83 of kacpherek's PRs): the 98 harnesses it can affect, clippy -D warnings, tests, lan_e2e in-frame and on the server thread.
This commit is contained in:
Ludovic Marie
2026-10-27 14:52:50 +01:00
committed by GitHub
2 changed files with 20 additions and 1 deletions
+7 -1
View File
@@ -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,
@@ -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) {