From b929c66adf10aafa97f904a5b1b11ed13d28992f Mon Sep 17 00:00:00 2001 From: Guy Liner Date: Sun, 2 Jan 2022 17:22:56 -0500 Subject: [PATCH 1/2] Removed mcl_util.rotate_axis_and_place function, replaced it with minetest.rotate_and_place --- mods/CORE/mcl_util/init.lua | 100 +++--------------------------------- 1 file changed, 7 insertions(+), 93 deletions(-) diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index d548f6cac..dec12d2e9 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -22,100 +22,14 @@ function table.update_nil(t, ...) return t end --- Based on minetest.rotate_and_place - ---[[ -Attempt to predict the desired orientation of the pillar-like node -defined by `itemstack`, and place it accordingly in one of 3 possible -orientations (X, Y or Z). - -Stacks are handled normally if the `infinitestacks` -field is false or omitted (else, the itemstack is not changed). -* `invert_wall`: if `true`, place wall-orientation on the ground and ground- - orientation on wall - -This function is a simplified version of minetest.rotate_and_place. -The Minetest function is seen as inappropriate because this includes mirror -images of possible orientations, causing problems with pillar shadings. -]] -function mcl_util.rotate_axis_and_place(itemstack, placer, pointed_thing, infinitestacks, invert_wall) - local unode = minetest.get_node_or_nil(pointed_thing.under) - if not unode then - return - end - local undef = minetest.registered_nodes[unode.name] - if undef and undef.on_rightclick then - undef.on_rightclick(pointed_thing.under, unode, placer, - itemstack, pointed_thing) - return - end - local fdir = minetest.dir_to_facedir(placer:get_look_dir()) - local wield_name = itemstack:get_name() - - local above = pointed_thing.above - local under = pointed_thing.under - local is_x = (above.x ~= under.x) - local is_y = (above.y ~= under.y) - local is_z = (above.z ~= under.z) - - local anode = minetest.get_node_or_nil(above) - if not anode then - return - end - local pos = pointed_thing.above - local node = anode - - if undef and undef.buildable_to then - pos = pointed_thing.under - node = unode - end - - if minetest.is_protected(pos, placer:get_player_name()) then - minetest.record_protection_violation(pos, placer:get_player_name()) - return - end - - local ndef = minetest.registered_nodes[node.name] - if not ndef or not ndef.buildable_to then - return - end - - local p2 - if is_y then - if invert_wall then - if fdir == 3 or fdir == 1 then - p2 = 12 - else - p2 = 6 - end - end - elseif is_x then - if invert_wall then - p2 = 0 - else - p2 = 12 - end - elseif is_z then - if invert_wall then - p2 = 0 - else - p2 = 6 - end - end - minetest.set_node(pos, {name = wield_name, param2 = p2}) - - if not infinitestacks then - itemstack:take_item() - return itemstack - end -end - --- Wrapper of above function for use as `on_place` callback (Recommended). --- Similar to minetest.rotate_node. +-- Creates a function that calls to the minetest +-- function minetest_rotate_and_place. It rotates +-- a block based on where it thinks the player is facing +-- at the moment. This is typically called by pillar-like nodes. function mcl_util.rotate_axis(itemstack, placer, pointed_thing) - mcl_util.rotate_axis_and_place(itemstack, placer, pointed_thing, - minetest.is_creative_enabled(placer:get_player_name()), - placer:get_player_control().sneak) + minetest.rotate_and_place(itemstack, placer, pointed_thing, + minetest.is_creative_enabled(placer:get_player_name())) + --placer:get_player_control().sneak) return itemstack end From f4e7911903624f9112a3d66c3962caed0d0150e8 Mon Sep 17 00:00:00 2001 From: Guy Liner Date: Sun, 2 Jan 2022 17:32:43 -0500 Subject: [PATCH 2/2] Removed a comment that was not needed and added a new line below the comment block --- mods/CORE/mcl_util/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index dec12d2e9..32c3b0dee 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -26,10 +26,10 @@ end -- function minetest_rotate_and_place. It rotates -- a block based on where it thinks the player is facing -- at the moment. This is typically called by pillar-like nodes. + function mcl_util.rotate_axis(itemstack, placer, pointed_thing) minetest.rotate_and_place(itemstack, placer, pointed_thing, minetest.is_creative_enabled(placer:get_player_name())) - --placer:get_player_control().sneak) return itemstack end