1
0
Fork 0

Merge pull request 'Prevent water mobs to classify solid blocks below them or the medium they are supposed to be in as dangerous' (#685) from Athemis/MineClone2:fix-mobs-dangerous-nodes into master

This commit is contained in:
Wuzzy 2020-05-05 00:10:53 +00:00
commit b59f0d6c6e
1 changed files with 17 additions and 5 deletions

View File

@ -317,9 +317,13 @@ local is_node_dangerous = function(self, nodename)
end
if minetest.registered_nodes[nn].drowning > 0 then
if self.breath_max ~= -1 then
-- check if the mob is water-breathing _and_ the block is water; only return true if neither is the case
-- this will prevent water-breathing mobs to classify water or e.g. sand below them as dangerous
if not self.breathes_in_water and minetest.get_item_group(nn, "water") ~= 0 then
return true
end
end
end
if minetest.registered_nodes[nn].damage_per_second > 0 then
return true
end
@ -2028,11 +2032,19 @@ 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
local is_in_danger = false
-- if mob is flying, only check for node it is currently in (no contact with node below)
if flight_check(self) then
is_in_danger = is_node_dangerous(self, self.standing_in)
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
lp = minetest.find_node_near(s, 5, {"group:solid"})
-- did we find land?