Fix the baby zombie villager, happy ghast and player hurt voice pitch

This commit is contained in:
Kacpherek
2026-10-26 22:43:18 +01:00
parent 4504223265
commit e0e484e44b
3 changed files with 13 additions and 8 deletions
-5
View File
@@ -719,11 +719,6 @@ impl Audio {
self.play(event, at, volume, pitch);
self.capture = capture;
}
/// `LivingEntity.handleDamageEvent`'s pitch, `(r - r) * 0.2 + 1`, drawn on the
/// client (the entity's own random there, never the server's world random).
pub fn hurt_pitch(&mut self) -> f32 {
(self.random.next_float() - self.random.next_float()) * 0.2 + 1.0
}
/// `AbstractWidget.playButtonClickSound`: an unseeded, relative UI sound.
pub fn play_button_click(&mut self) {
self.play_instance(
+2 -2
View File
@@ -69,8 +69,8 @@ impl Game<'_> {
/// `LivingEntity.handleDamageEvent` for the player: the hurt sound of the
/// source's `DamageEffects` (`Player.getHurtSound`).
pub(super) fn player_hurt_sound(&mut self, sound: &str, at: [f64; 3]) {
let pitch = self.audio.hurt_pitch();
self.audio.play(sound, Some(at), 1.0, pitch);
// Player.getVoicePitch: always 1.0.
self.audio.play(sound, Some(at), 1.0, 1.0);
}
/// `CombatTracker.recordDamage` for the motion events of this tick.
pub(super) fn record_combat(&mut self, events: &[MotionEvent]) {
+11 -1
View File
@@ -1968,8 +1968,18 @@ impl Mob {
}
/// LivingEntity.getVoicePitch.
pub fn voice_pitch(&mut self) -> f32 {
// HappyGhast.getVoicePitch: always 1.0, babies and all.
if self.species() == Species::HappyGhast {
return 1.0;
}
// ZombieVillager.getVoicePitch: babies are 2.0, not 1.5.
let baby = if self.species() == Species::ZombieVillager {
2.0
} else {
1.5
};
let pitch = (self.random.next_float() - self.random.next_float()) * 0.2
+ if self.is_baby() { 1.5 } else { 1.0 };
+ if self.is_baby() { baby } else { 1.0 };
// Bat.getVoicePitch: a little lower.
if self.species() == Species::Bat {
pitch * 0.95