From 7e585b0bdcef2533ed44e231976a4a6cfe647462 Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Mon, 13 Mar 2023 11:52:59 +0000 Subject: [PATCH] add check for 'injured' animation --- api.lua | 4 ++-- api.txt | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/api.lua b/api.lua index 9a574f7..b3a36ab 100644 --- a/api.lua +++ b/api.lua @@ -3036,8 +3036,8 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage) -- turn mob on knockback and play run/walk animation self:set_yaw((random(0, 360) - 180) / 180 * pi, 12) - if self.animation and self.animation.run_end then - self:set_animation("run") + if self.animation and self.animation.injured_end and damage >= 1 then + self:set_animation("injured") else self:set_animation("walk") end diff --git a/api.txt b/api.txt index 0a260c3..c97a513 100644 --- a/api.txt +++ b/api.txt @@ -249,6 +249,9 @@ functions needed for the mob to work properly which contains the following: 'shoot_start' shooting animation. 'shoot_end' 'shoot_speed' + 'injured_start' when hit or damaged > 1 hp (if not set then 'walk' is used) + 'injured_end' + 'injured_speed' 'die_start' death animation 'die_end' 'die_speed'