Fix clippy and format the passive mob fixes
This commit is contained in:
@@ -1522,13 +1522,12 @@ pub fn age_up(m: &mut Mob, seconds: i32, forced: bool) {
|
||||
}
|
||||
}
|
||||
/// `Animal.playEatingSound` (empty) and its overrides, as (sound, volume,
|
||||
/// pitch); `level` is the level's random. Pigs and cats use the classic sound
|
||||
/// set, like their other sounds here.
|
||||
/// pitch); `level` is the level's random. Pigs and cats play their sound
|
||||
/// variant's set.
|
||||
pub fn eating_sound(
|
||||
m: &mut Mob,
|
||||
level: &mut impl RandomSource,
|
||||
) -> Option<(&'static str, f32, f32)> {
|
||||
let baby = m.is_baby();
|
||||
// Mth.randomBetween(level.getRandom(), 0.8, 1.2).
|
||||
let mut between = || level.next_float() * 0.4 + 0.8;
|
||||
let (sound, volume, pitch, entity_sound) = match m.species() {
|
||||
@@ -1536,7 +1535,9 @@ pub fn eating_sound(
|
||||
Species::Armadillo | Species::Pig | Species::SulfurCube => {
|
||||
let sound = match m.species() {
|
||||
Species::Armadillo => "entity.armadillo.eat",
|
||||
Species::Pig => super::finalize::variant_sound(m, "eat").unwrap_or("entity.pig.eat"),
|
||||
Species::Pig => {
|
||||
super::finalize::variant_sound(m, "eat").unwrap_or("entity.pig.eat")
|
||||
}
|
||||
_ => "entity.small_sulfur_cube.eat",
|
||||
};
|
||||
let pitch = m.voice_pitch();
|
||||
|
||||
@@ -127,9 +127,9 @@ pub fn finalize(m: &mut Mob) {
|
||||
}
|
||||
match species {
|
||||
Species::Horse => {
|
||||
m.attrs.speed = (0.45 + r.next_double() * 0.3 + r.next_double() * 0.3
|
||||
+ r.next_double() * 0.3)
|
||||
* 0.25;
|
||||
m.attrs.speed =
|
||||
(0.45 + r.next_double() * 0.3 + r.next_double() * 0.3 + r.next_double() * 0.3)
|
||||
* 0.25;
|
||||
m.extra.vector[0] =
|
||||
0.4 + r.next_double() * 0.2 + r.next_double() * 0.2 + r.next_double() * 0.2;
|
||||
m.extra.variant = r.next_int_bound(7).unwrap_or(0) as u8;
|
||||
@@ -139,9 +139,10 @@ pub fn finalize(m: &mut Mob) {
|
||||
Species::ZombieHorse => {
|
||||
// ZombieHorse.generateZombieHorseJumpStrength and ...Speed.
|
||||
let d = 0.066_666_666_666_666_67;
|
||||
m.extra.vector[0] = 0.5 + r.next_double() * d + r.next_double() * d + r.next_double() * d;
|
||||
m.attrs.speed = (9.0 + r.next_double() + r.next_double() + r.next_double())
|
||||
/ f64::from(42.16f32);
|
||||
m.extra.vector[0] =
|
||||
0.5 + r.next_double() * d + r.next_double() * d + r.next_double() * d;
|
||||
m.attrs.speed =
|
||||
(9.0 + r.next_double() + r.next_double() + r.next_double()) / f64::from(42.16f32);
|
||||
}
|
||||
_ => {
|
||||
m.extra.vector[0] =
|
||||
|
||||
@@ -2081,7 +2081,10 @@ pub fn variant_sound(m: &Mob, kind: &str) -> Option<&'static str> {
|
||||
static IDS: Mutex<Option<HashMap<String, &'static str>>> = Mutex::new(None);
|
||||
let mut ids = IDS.lock().ok()?;
|
||||
let ids = ids.get_or_insert_with(HashMap::new);
|
||||
Some(*ids.entry(id).or_insert_with_key(|k| Box::leak(k.clone().into_boxed_str())))
|
||||
Some(
|
||||
*ids.entry(id)
|
||||
.or_insert_with_key(|k| Box::leak(k.clone().into_boxed_str())),
|
||||
)
|
||||
}
|
||||
/// The registry name of the game's variant index.
|
||||
pub fn variant_name(s: Species, index: u8) -> &'static str {
|
||||
|
||||
Reference in New Issue
Block a user