Check node rightclick for cacti and large plants

This commit is contained in:
Wuzzy 2017-03-29 23:42:28 +02:00
parent 30564e494e
commit 2dd774475f
2 changed files with 17 additions and 0 deletions

View File

@ -1168,6 +1168,14 @@ minetest.register_node("mcl_core:cactus", {
return itemstack
end
-- Call on_rightclick if the pointed node defines it
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
local a = pointed_thing.above
local node_above = minetest.get_node(a)
local node_below = minetest.get_node({x=a.x, y=a.y-1, z=a.z})

View File

@ -130,6 +130,15 @@ local function add_large_plant(name, desc, longdesc, bottom_img, top_img, inv_im
if pointed_thing.type ~= "node" then
--return
end
-- Call on_rightclick if the pointed node defines it
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
-- Check for a floor and a space of 1×2×1
local ptu_node = minetest.get_node(pointed_thing.under)
local bottom