Spawn egg: Make node on_rightclick take precedence

This commit is contained in:
Wuzzy 2019-08-25 18:47:10 +02:00
parent 355aa1d40d
commit d995fd381a

View File

@ -370,11 +370,23 @@ minetest.register_craftitem("tsm_pyramids:spawn_egg", {
liquids_pointable = false, liquids_pointable = false,
stack_max = 99, stack_max = 99,
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then if pointed_thing.type ~= "node" then
minetest.add_entity(pointed_thing.above,"tsm_pyramids:mummy")
if not minetest.settings:get_bool("creative_mode") then itemstack:take_item() end
return itemstack return itemstack
end end
-- am I clicking on something with existing on_rightclick function?
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
minetest.add_entity(pointed_thing.above,"tsm_pyramids:mummy")
if not minetest.settings:get_bool("creative_mode") then
itemstack:take_item()
end
return itemstack
end, end,
}) })