Frog: walk at vanilla's speed

Vanilla's frog uses a SmoothSwimmingMoveControl(85, 10, 0.02, 0.1, true), so
a walking frog covers 0.1 blocks a tick (its movement speed attribute is 1.0
and the controller's outside-water speed is 0.1). Horizon gave every generic
animal the plain ground controller, which drives the mob at the attribute
itself: a frog walked ten times too fast, jittered, teleported and flew
(#2213).

The regression test fails without the change.
This commit is contained in:
minimax-m3.1-flash
2026-10-27 04:59:19 +05:00
committed by levzzz
parent aef652c8af
commit 498de72da2
+52
View File
@@ -186,6 +186,20 @@ pub fn register(m: &mut Mob) {
if m.species() == Species::Turtle {
super::turtle::register(m);
}
if m.species() == Species::Frog {
// `Frog()`: SmoothSwimmingMoveControl(85, 10, 0.02, 0.1, true).
// The frog's movement speed is 1.0, so the controller's 0.1
// outside-water speed is what keeps a walking frog at
// vanilla's pace; the plain ground controller walks ten
// times too fast (#2213).
m.ai.mov.kind = super::control::MoveKind::SmoothSwimming {
max_turn_x: 85.0,
max_turn_y: 10.0,
in_water: 0.02,
outside: 0.1,
gravity: true,
};
}
}
Family::Inert => {}
Family::Witch => super::witch::register(m),
@@ -1701,3 +1715,41 @@ mod despawn_tests {
}
}
}
#[cfg(test)]
mod frog_tests {
use super::*;
use crate::mobs::MobTypes;
use crate::mobs::control::MoveKind;
use std::sync::Arc;
/// `Frog()`: `new SmoothSwimmingMoveControl<>(this, 85, 10, 0.02F, 0.1F, true)`.
/// The frog's movement speed is 1.0, so the controller's 0.1 outside-water
/// speed is what keeps a walking frog at vanilla's pace. The plain ground
/// controller walks it ten times too fast, which is the jitter, the
/// teleporting and the flying of #2213.
#[test]
fn a_frog_walks_at_the_vanilla_speed() {
let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION);
if !root.join("entity-types.json").exists() {
return;
}
let data = MobTypes::load(&root).unwrap();
let kind = Arc::new(data.types.get("minecraft:frog").unwrap().clone());
assert_eq!(kind.speed, 1.0, "the frog's movement speed attribute");
let mut m = Mob::new(1, kind, Vec3::new(0.0, 4.0, 0.0), 0.0);
register(&mut m);
assert_eq!(
m.ai.mov.kind,
MoveKind::SmoothSwimming {
max_turn_x: 85.0,
max_turn_y: 10.0,
in_water: 0.02,
outside: 0.1,
gravity: true,
}
);
}
}