Horse armor reduces the damage a horse takes
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user