forked from mtcontrib/homedecor_modpack
fix books and swing's on_place to handle CONTENT_IGNORE and CONTENT_UNKNOWN and to always return their itemstacks
This commit is contained in:
parent
40431fc050
commit
ffeac9a1bd
|
@ -59,15 +59,15 @@ for c in ipairs(bookcolors) do
|
|||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local plname = placer:get_player_name()
|
||||
local pos = pointed_thing.under
|
||||
local node = minetest.get_node(pos)
|
||||
local n = minetest.registered_nodes[node.name]
|
||||
if not n.buildable_to then
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
local def = node and minetest.registered_nodes[node.name]
|
||||
if not def or not def.buildable_to then
|
||||
pos = pointed_thing.above
|
||||
node = minetest.get_node(pos)
|
||||
n = minetest.registered_nodes[node.name]
|
||||
if not n.buildable_to then return end
|
||||
node = minetest.get_node_or_nil(pos)
|
||||
def = node and minetest.registered_nodes[node.name]
|
||||
if not def or not def.buildable_to then return itemstack end
|
||||
end
|
||||
if minetest.is_protected(pos, plname) then return end
|
||||
if minetest.is_protected(pos, plname) then return itemstack end
|
||||
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
minetest.set_node(pos, {
|
||||
name = "homedecor:book_"..color,
|
||||
|
@ -89,7 +89,7 @@ for c in ipairs(bookcolors) do
|
|||
if data.title and data.title ~= "" then
|
||||
meta:set_string("infotext", data.title)
|
||||
end
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
if not homedecor.expect_infinite_stacks then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
|
|
|
@ -249,13 +249,13 @@ homedecor.register("swing", {
|
|||
for i = 0, 4 do -- search up to 5 spaces downward from the ceiling for the first non-buildable-to node...
|
||||
height = i
|
||||
local testpos = { x=pos.x, y=pos.y-i-1, z=pos.z }
|
||||
local testnode = minetest.get_node(testpos)
|
||||
local testreg = core.registered_nodes[testnode.name]
|
||||
local testnode = minetest.get_node_or_nil(testpos)
|
||||
local testreg = testnode and core.registered_nodes[testnode.name]
|
||||
|
||||
if not testreg.buildable_to then
|
||||
if not testreg or not testreg.buildable_to then
|
||||
if i < 1 then
|
||||
minetest.chat_send_player(placer:get_player_name(), "No room under there to hang a swing.")
|
||||
return
|
||||
return itemstack
|
||||
else
|
||||
break
|
||||
end
|
||||
|
@ -274,12 +274,11 @@ homedecor.register("swing", {
|
|||
|
||||
if not homedecor.expect_infinite_stacks then
|
||||
itemstack:take_item()
|
||||
return itemstack
|
||||
end
|
||||
|
||||
else
|
||||
minetest.chat_send_player(placer:get_player_name(), "You have to point at the bottom side of an overhanging object to place a swing.")
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
for i = 0, 4 do
|
||||
|
|
Loading…
Reference in New Issue
Block a user