Open doors when right-clicking a door with a door.
And similarly, if we wield a door and right click any node that has an on_rightclick() handler, call the handler instead. Just to be on the safe side, assure that none of this code runs when right-clicking an entity or player, which would likely crash the server. Fold in PR #831 as well - prevent server crash on door place on unknown blocks, by @tenplus1.
This commit is contained in:
parent
bbf17c9eca
commit
2cc6640edf
|
@ -185,16 +185,26 @@ function doors.register(name, def)
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
local pos = nil
|
local pos = nil
|
||||||
|
|
||||||
|
if not pointed_thing.type == "node" then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
local node = minetest.get_node(pointed_thing.under)
|
local node = minetest.get_node(pointed_thing.under)
|
||||||
if minetest.registered_nodes[node.name].buildable_to then
|
local def = minetest.registered_nodes[node.name]
|
||||||
|
if def and def.on_rightclick then
|
||||||
|
return def.on_rightclick(pointed_thing.under,
|
||||||
|
node, placer, itemstack)
|
||||||
|
end
|
||||||
|
|
||||||
|
if def and def.buildable_to then
|
||||||
pos = pointed_thing.under
|
pos = pointed_thing.under
|
||||||
else
|
else
|
||||||
pos = pointed_thing.above
|
pos = pointed_thing.above
|
||||||
node = minetest.get_node(pos)
|
node = minetest.get_node(pos)
|
||||||
end
|
def = minetest.registered_nodes[node.name]
|
||||||
|
if not def or not def.buildable_to then
|
||||||
if not minetest.registered_nodes[node.name].buildable_to then
|
return itemstack
|
||||||
return itemstack
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local above = { x = pos.x, y = pos.y + 1, z = pos.z }
|
local above = { x = pos.x, y = pos.y + 1, z = pos.z }
|
||||||
|
|
Loading…
Reference in New Issue