Fix get_light crash

Elias Fleckenstein 2021-04-17 21:00:32 +02:00
parent baebe3c2d2
commit bcd058feb1

@ -1029,6 +1029,14 @@ local node_ok = function(pos, fallback)
return minetest.registered_nodes[fallback] return minetest.registered_nodes[fallback]
end end
local function get_light(pos)
if math.abs(pos.x) < 31000 and math.abs(pos.y) < 31000 and math.abs(pos.z) < 31000 then
local lightfunc = minetest.get_natural_light or minetest.get_node_light
return lightfunc(pos)
else
return 0
end
end
-- environmental damage (water, lava, fire, light etc.) -- environmental damage (water, lava, fire, light etc.)
local do_env_damage = function(self) local do_env_damage = function(self)
@ -1074,7 +1082,6 @@ local do_env_damage = function(self)
-- Use get_node_light for Minetest version 5.3 where get_natural_light -- Use get_node_light for Minetest version 5.3 where get_natural_light
-- does not exist yet. -- does not exist yet.
local get_light = minetest.get_natural_light or minetest.get_node_light
local sunlight = get_light(pos, self.time_of_day) local sunlight = get_light(pos, self.time_of_day)
-- bright light harms mob -- bright light harms mob