From bcd058feb1c1cd4bd24086a99838d3aa8cce8526 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sat, 17 Apr 2021 21:00:32 +0200 Subject: [PATCH] Fix get_light crash --- mods/ENTITIES/mcl_mobs/api.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 9182b11c..1b5715b2 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -1029,6 +1029,14 @@ local node_ok = function(pos, fallback) return minetest.registered_nodes[fallback] 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.) 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 -- 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) -- bright light harms mob