fix fence_with_signs check for content_ignore, prevent it to destroy unknown_nodes and always return the itemstack

This commit is contained in:
Tim 2015-09-10 09:39:58 +02:00
parent d763840b47
commit 40431fc050

View File

@ -858,21 +858,21 @@ function signs_lib.register_fence_with_sign(fencename, fencewithsignname)
fences_with_sign[fencename] = fencewithsignname
def_sign.on_place = function(itemstack, placer, pointed_thing, ...)
local node_above = minetest.get_node(pointed_thing.above)
local node_under = minetest.get_node(pointed_thing.under)
local def_above = minetest.registered_nodes[node_above.name]
local def_under = minetest.registered_nodes[node_under.name]
local node_above = minetest.get_node_or_nil(pointed_thing.above)
local node_under = minetest.get_node_or_nil(pointed_thing.under)
local def_above = node_above and minetest.registered_nodes[node_above.name]
local def_under = node_under and minetest.registered_nodes[node_under.name]
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
local playername = placer:get_player_name()
if minetest.is_protected(pointed_thing.under, playername) then
minetest.record_protection_violation(pointed_thing.under, playername)
return
return itemstack
end
if minetest.is_protected(pointed_thing.above, playername) then
minetest.record_protection_violation(pointed_thing.above, playername)
return
return itemstack
end
if def_under and def_under.on_rightclick then
@ -883,15 +883,14 @@ function signs_lib.register_fence_with_sign(fencename, fencewithsignname)
itemstack:take_item()
end
placer:set_wielded_item(itemstack)
return itemstack
elseif not def_above or def_above.buildable_to then
elseif def_above and def_above.buildable_to then
minetest.add_node(pointed_thing.above, {name = fencename, param2 = fdir})
if not signs_lib.expect_infinite_stacks then
itemstack:take_item()
end
placer:set_wielded_item(itemstack)
return itemstack
end
return itemstack
end
def_sign.on_construct = function(pos, ...)
signs_lib.construct_sign(pos)