From fcc485a8e3c2f643af6b0d0b529e946dd0716966 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Tue, 5 Jan 2021 14:40:54 +0100 Subject: [PATCH] Fix #904 --- mods/ITEMS/mcl_itemframes/init.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/mods/ITEMS/mcl_itemframes/init.lua b/mods/ITEMS/mcl_itemframes/init.lua index 40321efe..99f7fbc3 100644 --- a/mods/ITEMS/mcl_itemframes/init.lua +++ b/mods/ITEMS/mcl_itemframes/init.lua @@ -147,6 +147,34 @@ minetest.register_node("mcl_itemframes:item_frame",{ sunlight_propagates = true, groups = { dig_immediate=3,deco_block=1,dig_by_piston=1,container=7 }, sounds = mcl_sounds.node_sound_defaults(), + on_place = function(itemstack, placer, pointed_thing) + if pointed_thing.type ~= "node" then + return itemstack + end + + -- Use pointed node's on_rightclick function first, if present + local node = minetest.get_node(pointed_thing.under) + if placer and not placer:get_player_control().sneak then + if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then + return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack + end + end + + if pointed_thing.above.y ~= pointed_thing.under.y then + return itemstack + end + + if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].buildable_to then + return itemstack + end + + local new_itemstack, success = minetest.item_place(itemstack, placer, pointed_thing) + local node = minetest.get_node(pointed_thing.above) + node.param2 = minetest.dir_to_facedir(vector.direction(pointed_thing.above, pointed_thing.under)) + minetest.swap_node(pointed_thing.above, node) + + return new_itemstack + end, on_construct = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory()