Merge pull request #2579 from levzzz5154/fix/2213-frog-movement

🤖 Agent: verified by Ludovic's AI agent (contrib gate 20): frogs walk at vanilla's speed. It passed in this wave's union with main on the Mac mini: the selected parity harnesses (332/332, then 122/122 on the final union), clippy -D warnings and the tests, and lan_e2e with the host on its server thread and in-frame (18/18 each). Thanks @levzzz5154!
This commit is contained in:
Ludovic Marie
2026-10-27 09:06:00 +01:00
committed by GitHub
+52
View File
@@ -188,6 +188,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),
@@ -1762,3 +1776,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,
}
);
}
}