From b7ba16f4cdf9a50cd59ba6215ff113e1ff6dc231 Mon Sep 17 00:00:00 2001 From: Alexander Minges Date: Fri, 1 May 2020 14:56:29 +0200 Subject: [PATCH] fix detection of dangerous location for flying mobs --- mods/ENTITIES/mcl_mobs/api.lua | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 4a4a56bb..c027ce16 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -2032,11 +2032,21 @@ local do_states = function(self, dtime) local is_in_danger = false if lp then - -- If mob in or on dangerous block, look for land - if (is_node_dangerous(self, self.standing_in) or + -- if mob is flying, check if it is in its preferred medium + if self.fly then + if minetest.get_item_group(self.standing_in, self.fly_in) then + is_in_danger = false + elseif is_node_dangerous(self, self.standing_in) then + is_in_danger = true + end + elseif (is_node_dangerous(self, self.standing_in) or is_node_dangerous(self, self.standing_on)) then is_in_danger = true - + end + -- If mob in or on dangerous block, look for land + if is_in_danger then + minetest.log(self.name .. " is in/on dangerous node " .. self.standing_on .. " or " .. self.standing_in) + minetest.log(self.water_damage) lp = minetest.find_node_near(s, 5, {"group:solid"}) -- did we find land?