From 0c2ddab17274c229f605d28af75baeebe4e65e10 Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Mon, 13 Mar 2023 11:24:52 +0000 Subject: [PATCH] fix env timer issue --- api.lua | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/api.lua b/api.lua index 0196dea..9a574f7 100644 --- a/api.lua +++ b/api.lua @@ -3479,6 +3479,20 @@ function mob_class:on_step(dtime, moveresult) self.object:set_yaw(yaw) end + -- environmental damage timer (every 1 second) + self.env_damage_timer = self.env_damage_timer + dtime + + if self.env_damage_timer > 1 then + + self.env_damage_timer = 0 + + -- check for environmental damage (water, fire, lava etc.) + if self:do_env_damage() then return end + + -- node replace check (cow eats grass etc.) + self:replace(pos) + end + -- knockback timer if self.pause_timer > 0 then @@ -3518,21 +3532,6 @@ function mob_class:on_step(dtime, moveresult) self:mob_sound(self.sounds.random) end - -- environmental damage timer (every 1 second) - self.env_damage_timer = self.env_damage_timer + dtime - - if (self.state == "attack" and self.env_damage_timer > 1) - or self.state ~= "attack" then - - self.env_damage_timer = 0 - - -- check for environmental damage (water, fire, lava etc.) - if self:do_env_damage() then return end - - -- node replace check (cow eats grass etc.) - self:replace(pos) - end - self:general_attack() self:breed()