Give custom mobs a "damage taken animation"
Hello Datapack Hub-Community, I've been trying to add a custom mob to the game, but can't seem to figure out how to add a "turning red animation", when the mob takes damage. In the past I've done this with detecting the HurtTime and changing the model at 10 and 1, but for some reason this doesn't work.
If anyone has experience on this topic, I appreciate every kind of help. -# The datapack is in Java, 1.21.8
How I used to do it back in 1.20: tick.mcfunction:
execute as @e[tag=butterfly_orange,type=bat] at @s if entity @a[distance=0..10] run function koetelkind:butterfly_orange_damagebutterfly_orange_damage.mcfunction:##1 execute if entity @s[nbt={HurtTime:10}] run data merge entity @e[limit=1,distance=0..2,type=armor_stand,sort=nearest,tag=butterfly_orange] {ArmorItems:[{},{},{},{id:"minecraft:paper",count:1,components:{"minecraft:custom_model_data":{strings:["butterfly_damage"]}}}]} ##2 execute if entity @s[nbt={HurtTime:1}] run data merge entity @e[limit=1,distance=0..2,type=armor_stand,sort=nearest,tag=butterfly_orange] {ArmorItems:[{},{},{},{id:"minecraft:paper",count:1,components:{"minecraft:custom_model_data":{strings:["butterfly_orange"]}}}]}