Merge pull request 'Choose alternative position if head position isn't suitable' (#4) from j-r/mcl_wieldlight:alternative_position into main

Reviewed-on: https://codeberg.org/mineclonia/mcl_wieldlight/pulls/4
Reviewed-by: cora <cora@noreply.codeberg.org>
This commit is contained in:
cora 2024-11-09 14:57:01 +00:00
commit b242efdaf6

View File

@ -26,8 +26,15 @@ local function update_player_light(pl)
local ol = minetest.registered_items[offhand] and minetest.registered_items[offhand].light_source or 0
local light = math.min(math.max(wl,ol,0),minetest.LIGHT_MAX)
local p = vector.round(vector.offset(pl:get_pos(),0,1,0))
local ph = minetest.hash_node_position(p)
local n = minetest.get_node(p)
if n.name ~= "air" and minetest.get_item_group(n.name, "wieldlight") == 0 then
local ap = minetest.find_node_near(p, 1, {"air", "group:wieldlight"})
if ap then
p = ap
n = minetest.get_node(p)
end
end
local ph = minetest.hash_node_position(p)
local has_light = false
local rm = {}
for h,v in pairs(placed_lights[pl] or {}) do