From 3c7942d2bd53e2ae6508b851b18b0025c73d18a7 Mon Sep 17 00:00:00 2001 From: levzzz <86072227+levzzz5154@users.noreply.github.com> Date: Tue, 27 Oct 2026 19:14:31 +0500 Subject: [PATCH] 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) --- crates/horizon-client/src/mobs/armadillo.rs | 40 +++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/crates/horizon-client/src/mobs/armadillo.rs b/crates/horizon-client/src/mobs/armadillo.rs index 8837d8cf8..1deb7f11b 100644 --- a/crates/horizon-client/src/mobs/armadillo.rs +++ b/crates/horizon-client/src/mobs/armadillo.rs @@ -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"); + } +}