Test that a hit rolls the armadillo up into a ball

An armadillo hit by a living thing curls up: Armadillo.actuallyHurt
rolls it up, Armadillo.rollUp plays entity.armadillo.roll and switches
the state to ROLLING, and ArmadilloState.shouldHideInShell then shows
the shell instead of the armadillo. The roll itself is on main (#2535),
but nothing held it in place, so this test pins it: a hit rolls the
armadillo up, the roll plays its sound and the model shows the shell
(#2759).

Co-Authored-By: minimax-m3.1-flash (Claude Code) <noreply@users.noreply.github.com>
This commit is contained in:
levzzz
2026-10-27 19:14:31 +05:00
parent 30c58b6591
commit 3c7942d2bd
@@ -405,3 +405,43 @@ impl Goal for Rolled {
scared(m)
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::mobs::sensor_scan_tests::kind;
use std::sync::Arc;
/// An armadillo on the ground.
fn armadillo() -> Mob {
let mut kind = kind();
let k = Arc::make_mut(&mut kind);
k.id = "minecraft:armadillo".into();
k.species = Species::Armadillo;
let mut m = Mob::new(1, kind, Vec3::ZERO, 0.0);
m.on_ground = true;
m
}
#[test]
fn a_hit_rolls_it_up_into_a_ball() {
// Armadillo.actuallyHurt: a hit by a living thing curls it up and
// keeps the danger in mind for 80 ticks, so the model shows the
// shell instead of the armadillo (#2759).
let mut m = armadillo();
after_hurt(&mut m, &Damage::player([0.0, 0.0, 0.0]));
assert_eq!(state(&m), ROLLING);
// Armadillo.rollUp: the roll sound.
assert!(
m.outbox
.iter()
.any(|e| matches!(e, MobEvent::Sound(s, ..) if *s == "entity.armadillo.roll")),
"the roll plays its sound"
);
// ArmadilloState.shouldHideInShell: the shell shows after five ticks.
for _ in 0..6 {
tick(&mut m);
}
assert!(hiding_in_shell(&m), "the model shows the shell");
}
}