Merge pull request '[heads] heads may now be placed on ceilings, upside down' (#2558) from heads_ceiling into master

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/2558
Reviewed-by: cora <cora@noreply.git.minetest.land>
This commit is contained in:
cora 2022-08-12 21:39:14 +00:00
commit 0debaf12c0
1 changed files with 4 additions and 2 deletions

View File

@ -122,18 +122,20 @@ function mcl_heads.deftemplate_floor.on_place(itemstack, placer, pointed_thing)
if wdir ~= 0 and wdir ~= 1 then
placestack:set_name(itemstring .."_wall")
itemstack = minetest.item_place(placestack, placer, pointed_thing, wdir)
-- place floor head node (floor and ceiling)
else
local fdir = minetest.dir_to_facedir(dir)
-- determine the head node rotation based on player's yaw (in cw direction from North/Z+)
local yaw = math.pi*2 - placer:get_look_horizontal()
local yaw = placer:get_look_horizontal()
yaw = wdir == 1 and math.pi*2 - yaw or yaw
local rotation_level = math.min(math.max(math.round((yaw / (math.pi*2)) * 16), 0), 15)
placestack:set_name(itemstring ..mcl_heads.FLOOR_DEGREES[rotation_level % 4])
-- determine the head node face direction based on rotation level
fdir = math.floor(rotation_level / 4)
fdir = math.floor(rotation_level / 4) + (wdir == 1 and 0 or 20)
itemstack = minetest.item_place(placestack, placer, pointed_thing, fdir)
end