Skip to content

Commit 45e4829

Browse files
authored
Pointed_thing_to_face_pos: Avoid crash when player is inside a node (#7342)
Avoid crash in some situations when player is inside a node, causing 'above' to equal 'under'. In this situation return 'under' which is the node position very close to the face position that would normally be returned.
1 parent 04f7962 commit 45e4829

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

builtin/common/misc_helpers.lua

+6
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,12 @@ end
685685
-- Returns the exact coordinate of a pointed surface
686686
--------------------------------------------------------------------------------
687687
function core.pointed_thing_to_face_pos(placer, pointed_thing)
688+
-- Avoid crash in some situations when player is inside a node, causing
689+
-- 'above' to equal 'under'.
690+
if vector.equals(pointed_thing.above, pointed_thing.under) then
691+
return pointed_thing.under
692+
end
693+
688694
local eye_height = placer:get_properties().eye_height
689695
local eye_offset_first = placer:get_eye_offset()
690696
local node_pos = pointed_thing.under

0 commit comments

Comments
 (0)