Merge pull request #2247 from kacpherek/fix/ambient-intervals
🤖 Agent: Read against the vanilla 26.3 sources (Use vanilla ambient sound intervals for guardians, hoglins, shulkers and allays) and proven in contrib-gate-21's union of 72 kacpherek PRs: 95 parity harnesses on playhorizon and the Mac mini, clippy, 1534 tests, lan_e2e 23 checks in-frame and with --server-thread. Thanks @kacpherek!
This commit is contained in:
@@ -1925,7 +1925,7 @@ impl Mob {
|
||||
let dead = !self.alive();
|
||||
let sound = ai::voice_sounds(self)[if dead { 2 } else { 1 }];
|
||||
if !dead {
|
||||
self.ambient_timer = -self.kind.ambient_interval;
|
||||
self.ambient_timer = -self.ambient_interval();
|
||||
}
|
||||
if !sound.is_empty() {
|
||||
let pitch = self.voice_pitch();
|
||||
@@ -2035,6 +2035,16 @@ impl Mob {
|
||||
let at = [self.position.x, self.eye_y(), self.position.z];
|
||||
events.push(MobEvent::Sound(event, at, 1.0, 1.0));
|
||||
}
|
||||
/// `Mob.getAmbientSoundInterval`; `HappyGhast` waits six times as long
|
||||
/// while it carries a passenger.
|
||||
pub fn ambient_interval(&self) -> i32 {
|
||||
let ridden = self.rider.is_some() || self.extra.rider.is_some();
|
||||
if self.species() == Species::HappyGhast && ridden {
|
||||
self.kind.ambient_interval * 6
|
||||
} else {
|
||||
self.kind.ambient_interval
|
||||
}
|
||||
}
|
||||
/// LivingEntity.getVoicePitch.
|
||||
pub fn voice_pitch(&mut self) -> f32 {
|
||||
// HappyGhast.getVoicePitch: always 1.0, babies and all.
|
||||
|
||||
@@ -635,7 +635,7 @@ fn base_tick(m: &mut Mob, w: &MobWorld, events: &mut Vec<MobEvent>) {
|
||||
let t = m.ambient_timer;
|
||||
m.ambient_timer += 1;
|
||||
if roll < t {
|
||||
m.ambient_timer = -m.kind.ambient_interval;
|
||||
m.ambient_timer = -m.ambient_interval();
|
||||
play_ambient(m, w, events);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1661,6 +1661,12 @@ impl Def {
|
||||
| S::Camel
|
||||
| S::CamelHusk => 400,
|
||||
S::Ocelot => 900,
|
||||
// Guardian.getAmbientSoundInterval (the elder too).
|
||||
S::Guardian | S::ElderGuardian => 160,
|
||||
// Hoglin extends Animal; Shulker extends AbstractGolem.
|
||||
S::Hoglin | S::Shulker => 120,
|
||||
// Allay is a PathfinderMob: the Mob default.
|
||||
S::Allay => 80,
|
||||
S::Squid
|
||||
| S::GlowSquid
|
||||
| S::Cod
|
||||
|
||||
Reference in New Issue
Block a user