1
0
Fork 0

[heads] heads may now be placed on ceilings, upside down

mobs-redo
iliekprogrammar 2022-08-13 00:13:12 +08:00
parent 1bc082ee4f
commit 7482f84929
No known key found for this signature in database
GPG Key ID: 8E7B20514DBCFBFA
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 if wdir ~= 0 and wdir ~= 1 then
placestack:set_name(itemstring .."_wall") placestack:set_name(itemstring .."_wall")
itemstack = minetest.item_place(placestack, placer, pointed_thing, wdir) itemstack = minetest.item_place(placestack, placer, pointed_thing, wdir)
-- place floor head node (floor and ceiling) -- place floor head node (floor and ceiling)
else else
local fdir = minetest.dir_to_facedir(dir) local fdir = minetest.dir_to_facedir(dir)
-- determine the head node rotation based on player's yaw (in cw direction from North/Z+) -- 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) 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]) placestack:set_name(itemstring ..mcl_heads.FLOOR_DEGREES[rotation_level % 4])
-- determine the head node face direction based on rotation level -- 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) itemstack = minetest.item_place(placestack, placer, pointed_thing, fdir)
end end