From aae38372225c7a01705ca64e08bcb37e41f6d7b0 Mon Sep 17 00:00:00 2001 From: luk3yx Date: Fri, 10 Mar 2023 13:20:03 +1300 Subject: [PATCH] Catch InvalidPositionException in get_natural_light --- src/script/lua_api/l_env.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp index 8c3a1985c..68aec1b53 100644 --- a/src/script/lua_api/l_env.cpp +++ b/src/script/lua_api/l_env.cpp @@ -440,8 +440,13 @@ int ModApiEnvMod::l_get_natural_light(lua_State *L) // If it's the same as the artificial light, the sunlight needs to be // searched for because the value may not emanate from the sun - if (daylight == n.param1 >> 4) - daylight = env->findSunlight(pos); + try { + if (daylight == n.param1 >> 4) + daylight = env->findSunlight(pos); + } catch (InvalidPositionException &e) { + errorstream << "InvalidPositionException when getting natural light at " + << PP(pos) << std::endl; + } lua_pushinteger(L, dnr * daylight / 1000); return 1;