From 6c3defa821dd767413e421b5ada81759f83a47b5 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 22:16:09 +0100 Subject: [PATCH] Hit with a hoglin or zoglin every 40 ticks, 15 for a baby HoglinAi and Zoglin use MeleeAttack.create(40) for adults and create(15) for babies; Horizon used the 20-tick default. --- crates/horizon-client/src/mobs/goals.rs | 15 ++++++++++++++- crates/horizon-client/src/mobs/piglin.rs | 6 ++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/crates/horizon-client/src/mobs/goals.rs b/crates/horizon-client/src/mobs/goals.rs index e4682b0de..8a72c1e8a 100644 --- a/crates/horizon-client/src/mobs/goals.rs +++ b/crates/horizon-client/src/mobs/goals.rs @@ -1065,6 +1065,8 @@ pub struct MeleeAttack { raise_arm: i32, /// Ticks between attacks (20 unless set). pub interval: i32, + /// Ticks between attacks for a baby, when they differ. + pub baby_interval: Option, } impl MeleeAttack { pub fn new(speed: f64, follow_unseen: bool) -> Self { @@ -1079,6 +1081,7 @@ impl MeleeAttack { last_check: 0, raise_arm: 0, interval: 20, + baby_interval: None, } } pub fn zombie(mut self) -> Self { @@ -1093,6 +1096,12 @@ impl MeleeAttack { self.interval = ticks; self } + /// `MeleeAttack.create(adult)` for adults, `create(baby)` for babies. + pub fn intervals(mut self, adult: i32, baby: i32) -> Self { + self.interval = adult; + self.baby_interval = Some(baby); + self + } } impl Goal for MeleeAttack { goal_clone!(); @@ -1191,7 +1200,11 @@ impl Goal for MeleeAttack { cx, ); } else if self.until_attack <= 0 && m.within_melee_range(&t) && m.sees(cx.w, who) { - self.until_attack = adjusted(true, self.interval); + let interval = match self.baby_interval { + Some(baby) if m.is_baby() => baby, + _ => self.interval, + }; + self.until_attack = adjusted(true, interval); m.swing(); super::ai::do_hurt_target(m, who, cx); } diff --git a/crates/horizon-client/src/mobs/piglin.rs b/crates/horizon-client/src/mobs/piglin.rs index aaaaf4dda..aa6d7bb09 100644 --- a/crates/horizon-client/src/mobs/piglin.rs +++ b/crates/horizon-client/src/mobs/piglin.rs @@ -169,7 +169,8 @@ pub fn register_hoglin(m: &mut Mob) { let g = &mut m.ai.goals; g.add(0, Float); g.add(1, BabyPanic(super::goals::Panic::new(1.25))); - g.add(2, MeleeAttack::new(1.0, true)); + // HoglinAi: MeleeAttack.create(40) for adults, 15 for babies. + g.add(2, MeleeAttack::new(1.0, true).intervals(40, 15)); g.add(3, super::goals::Breed::new(1.0)); g.add(3, HoglinAvoidRepellent); g.add(4, super::goals::FollowParent::new(1.1)); @@ -185,7 +186,8 @@ pub fn register_hoglin(m: &mut Mob) { pub fn register_zoglin(m: &mut Mob) { let g = &mut m.ai.goals; g.add(0, Float); - g.add(2, MeleeAttack::new(1.0, true)); + // Zoglin.initMemories: MeleeAttack.create(40) for adults, 15 for babies. + g.add(2, MeleeAttack::new(1.0, true).intervals(40, 15)); g.add(5, Stroll::avoiding_water(0.4)); g.add(6, LookAtPlayer::new(8.0)); m.ai.targets.add(1, HurtByTarget::new());