Use vanilla's head turn limits for guardian, shulker, ravager, camel and sitting wolf, and draw a parrot in water as flying

This commit is contained in:
Kacpherek
2026-10-26 22:49:24 +01:00
parent 840d11a3b2
commit c05dc8af22
5 changed files with 20 additions and 15 deletions
+2 -1
View File
@@ -980,9 +980,10 @@ pub fn anim(m: &Mob, s: &State, p: &mut Poses, a: &Animations) -> bool {
Species::Parrot => {
let flap = m.anim.flap_o + (m.anim.flap - m.anim.flap_o) * s.partial;
let speed = m.anim.flap_speed_o + (m.anim.flap_speed - m.anim.flap_speed_o) * s.partial;
// `Parrot.isFlying` is `!onGround`, in water too.
let pose = if m.extra.sitting {
ParrotPose::Sitting
} else if !m.on_ground && !m.fluids.in_water {
} else if !m.on_ground {
ParrotPose::Flying
} else {
ParrotPose::Standing
+10 -2
View File
@@ -1,6 +1,6 @@
//! Mob controls: `MoveControl` (with the flying and smooth-swimming
//! variants), `LookControl`, `JumpControl` and `BodyRotationControl`.
use super::{Mob, MobWorld, living::wrap};
use super::{Mob, MobWorld, Species, living::wrap};
use horizon_core::geometry::trig;
/// `2.5000003E-7F` widened: the squared distance controls treat as arrived.
@@ -113,8 +113,16 @@ pub struct BodyRotation {
last_stable_head: f32,
}
impl Mob {
/// `Mob.getMaxHeadXRot`, with `Wolf`'s 20 degrees while sitting.
pub fn max_head_x_rot(&self) -> f32 {
if self.species() == Species::Wolf && self.extra.sitting {
20.0
} else {
self.kind.max_head_x_rot
}
}
pub fn look_at(&mut self, at: [f64; 3]) {
let (y, x) = (self.kind.head_rot_speed, self.kind.max_head_x_rot);
let (y, x) = (self.kind.head_rot_speed, self.max_head_x_rot());
self.ai.look.set_look_at(at, y, x);
}
pub fn look_at_speed(&mut self, at: [f64; 3], y_speed: f32, x_max: f32) {
+2 -2
View File
@@ -1741,7 +1741,7 @@ impl Goal for Tempt {
}
fn tick(&mut self, m: &mut Mob, cx: &mut Cx) {
let Some(p) = cx.w.player.clone() else { return };
let (y, x) = (m.kind.max_head_y_rot + 20.0, m.kind.max_head_x_rot);
let (y, x) = (m.kind.max_head_y_rot + 20.0, m.max_head_x_rot());
m.look_at_speed(p.eye, y, x);
if m.distance_sqr(p.position) < self.stop_distance * self.stop_distance {
m.nav_stop();
@@ -1850,7 +1850,7 @@ impl Goal for Breed {
let Some(p) = self.partner.and_then(|p| cx.w.seen(p)).cloned() else {
return;
};
let x = m.kind.max_head_x_rot;
let x = m.max_head_x_rot();
m.look_at_speed([p.position.x, p.eye_y, p.position.z], 10.0, x);
m.nav_move_to_entity(
cx.w,
@@ -1629,6 +1629,7 @@ impl Def {
match self.species {
Species::Dolphin | Species::Axolotl => 1.0,
Species::Slime | Species::MagmaCube | Species::SulfurCube => 0.0,
Species::Guardian | Species::ElderGuardian | Species::Shulker => 180.0,
_ => 40.0,
}
}
@@ -1640,6 +1641,9 @@ impl Def {
Species::Sniffer => 50.0,
Species::Goat => 15.0,
Species::Armadillo => 32.0,
Species::Ravager => 45.0,
Species::Camel | Species::CamelHusk => 30.0,
Species::Shulker => 180.0,
_ => 75.0,
}
}
+2 -10
View File
@@ -360,7 +360,7 @@ impl Goal for FollowOwner {
};
let far = m.distance_sqr(at) >= 144.0;
if !far {
let max = max_head_x_rot(m);
let max = m.max_head_x_rot();
m.look_at_speed([at.x, eye, at.z], 10.0, max);
}
self.recalc -= 1;
@@ -507,7 +507,7 @@ impl Goal for Beg {
}
fn tick(&mut self, m: &mut Mob, cx: &mut Cx) {
if let Some(p) = &cx.w.player {
let max = max_head_x_rot(m);
let max = m.max_head_x_rot();
m.look_at_speed([p.position.x, p.eye[1], p.position.z], 10.0, max);
}
self.ticks -= 1;
@@ -683,14 +683,6 @@ pub fn texture(m: &Mob) -> String {
let baby = if m.is_baby() { "_baby" } else { "" };
format!("entity/wolf/{file}{state}{baby}")
}
/// `Wolf.getMaxHeadXRot`: 20 degrees while sitting.
fn max_head_x_rot(m: &Mob) -> f32 {
if m.extra.sitting {
20.0
} else {
m.kind.max_head_x_rot
}
}
/// Cat variants (`CatVariants`): registry name, texture file.
pub const CAT_VARIANTS: [&str; 11] = [