From 86bc398a7932cbce49c2a077549a0341f5ffd981 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 22 May 2022 19:46:10 +0200 Subject: [PATCH] don't do flying animation while perching,fix anims --- mods/ENTITIES/mcl_mobs/api.lua | 62 ++++++++++++++++---------------- mods/ENTITIES/mobs_mc/parrot.lua | 8 ++--- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 6b2cff0e3..933634cce 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -363,6 +363,35 @@ local remove_texture_mod = function(self, mod) self.object:set_texture_mod(full_mod) end +-- are we flying in what we are suppose to? (taikedz) +local flight_check = function(self) + + local nod = self.standing_in + local def = minetest.registered_nodes[nod] + + if not def then return false end -- nil check + + local fly_in + if type(self.fly_in) == "string" then + fly_in = { self.fly_in } + elseif type(self.fly_in) == "table" then + fly_in = self.fly_in + else + return false + end + + for _,checknode in pairs(fly_in) do + if nod == checknode then + return true + elseif checknode == "__airlike" or def.walkable == false and + (def.liquidtype == "none" or minetest.get_item_group(nod, "fake_liquid") == 1) then + return true + end + end + + return false +end + -- set defined animation local set_animation = function(self, anim, fixed_frame) if not self.animation or not anim then @@ -372,6 +401,8 @@ local set_animation = function(self, anim, fixed_frame) return end + if flight_check(self) and self.fly and anim == "walk" then anim = "fly" end + self.animation.current = self.animation.current or "" if (anim == self.animation.current @@ -513,37 +544,6 @@ local line_of_sight = function(self, pos1, pos2, stepsize) return false end - --- are we flying in what we are suppose to? (taikedz) -local flight_check = function(self) - - local nod = self.standing_in - local def = minetest.registered_nodes[nod] - - if not def then return false end -- nil check - - local fly_in - if type(self.fly_in) == "string" then - fly_in = { self.fly_in } - elseif type(self.fly_in) == "table" then - fly_in = self.fly_in - else - return false - end - - for _,checknode in pairs(fly_in) do - if nod == checknode then - return true - elseif checknode == "__airlike" and def.walkable == false and - (def.liquidtype == "none" or minetest.get_item_group(nod, "fake_liquid") == 1) then - return true - end - end - - return false -end - - -- custom particle effects local effect = function(pos, amount, texture, min_size, max_size, radius, gravity, glow, go_down) diff --git a/mods/ENTITIES/mobs_mc/parrot.lua b/mods/ENTITIES/mobs_mc/parrot.lua index a17838d10..cf380e1c9 100644 --- a/mods/ENTITIES/mobs_mc/parrot.lua +++ b/mods/ENTITIES/mobs_mc/parrot.lua @@ -73,12 +73,12 @@ mcl_mobs:register_mob("mobs_mc:parrot", { stand_speed = 50, walk_speed = 50, fly_speed = 50, - stand_start = 30, - stand_end = 45, + stand_start = 0, + stand_end = 0, fly_start = 30, fly_end = 45, - walk_start = 30, - walk_end = 45, + walk_start = 0, + walk_end = 20, -- TODO: actual walk animation --walk_start = 0, --walk_end = 20,