1
0
Fork 0

Fix mobs despawning while close to player

This commit is contained in:
Lizzy Fleckenstein 2021-01-03 15:10:50 +01:00
parent 0fe1707c2f
commit 9e97331bdc
1 changed files with 15 additions and 15 deletions

View File

@ -647,9 +647,9 @@ local item_drop = function(self, cooked, looting_level)
-- no drops if disabled by setting -- no drops if disabled by setting
if not mobs_drop_items then return end if not mobs_drop_items then return end
looting_level = looting_level or 0 looting_level = looting_level or 0
-- no drops for child mobs (except monster) -- no drops for child mobs (except monster)
if (self.child and self.type ~= "monster") then if (self.child and self.type ~= "monster") then
return return
@ -938,7 +938,7 @@ local is_at_cliff_or_danger = function(self)
return true return true
else else
local def = minetest.registered_nodes[bnode.name] local def = minetest.registered_nodes[bnode.name]
if def and def.walkable then if def and def.walkable then
return false return false
end end
end end
@ -951,7 +951,7 @@ end
-- copy the 'mob facing cliff_or_danger check' from above, and rework to avoid water -- copy the 'mob facing cliff_or_danger check' from above, and rework to avoid water
local is_at_water_danger = function(self) local is_at_water_danger = function(self)
if not self.object:get_luaentity() then if not self.object:get_luaentity() then
return false return false
end end
@ -976,7 +976,7 @@ local is_at_water_danger = function(self)
return true return true
else else
local def = minetest.registered_nodes[bnode.name] local def = minetest.registered_nodes[bnode.name]
if def and def.walkable then if def and def.walkable then
return false return false
end end
end end
@ -2350,10 +2350,10 @@ local do_states = function(self, dtime)
lp = minetest.find_nodes_in_area_under_air( lp = minetest.find_nodes_in_area_under_air(
{x = s.x - 5, y = s.y - 0.5, z = s.z - 5}, {x = s.x - 5, y = s.y - 0.5, z = s.z - 5},
{x = s.x + 5, y = s.y + 1, z = s.z + 5}, {x = s.x + 5, y = s.y + 1, z = s.z + 5},
{"group:solid"}) {"group:solid"})
lp = #lp > 0 and lp[random(#lp)] lp = #lp > 0 and lp[random(#lp)]
-- did we find land? -- did we find land?
if lp then if lp then
@ -3598,15 +3598,15 @@ local mob_step = function(self, dtime)
for n = 1, #close_objs do for n = 1, #close_objs do
if close_objs[n]:is_player() then if close_objs[n]:is_player() then
self.lifetimer = 20 self.lifetimer = 20
else return
if math.random(1,10) <= 3 then
minetest.log("action", "Mob "..self.name.." despawns in mob_step at "..minetest.pos_to_string(pos))
mcl_burning.extinguish(self.object)
self.object:remove()
return
end
end end
end end
if math.random(1, 10) <= 3 then
minetest.log("action", "Mob "..self.name.." despawns in mob_step at "..minetest.pos_to_string(pos))
mcl_burning.extinguish(self.object)
self.object:remove()
return
end
else else
minetest.log("action", "Mob "..self.name.." despawns in mob_step at "..minetest.pos_to_string(pos)) minetest.log("action", "Mob "..self.name.." despawns in mob_step at "..minetest.pos_to_string(pos))
mcl_burning.extinguish(self.object) mcl_burning.extinguish(self.object)
@ -3842,7 +3842,7 @@ minetest.register_entity(name, {
get_staticdata = function(self) get_staticdata = function(self)
return mob_staticdata(self) return mob_staticdata(self)
end, end,
harmed_by_heal = def.harmed_by_heal, harmed_by_heal = def.harmed_by_heal,
}) })