Spawn egg, boat, cart, book use node rightclick

This commit is contained in:
Wuzzy 2017-03-02 15:44:31 +01:00
parent 711ec5f38c
commit b68224a38d
4 changed files with 46 additions and 0 deletions

View file

@ -2821,6 +2821,14 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
on_place = function(itemstack, placer, pointed_thing)
-- 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 pos = pointed_thing.above
if pos

View file

@ -152,6 +152,15 @@ for w=1, #woods do
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
if not is_water(pointed_thing.under) then
return
end

View file

@ -13,6 +13,16 @@ minetest.register_craft({
})
local write = function(itemstack, user, pointed_thing)
-- Call on_rightclick if the pointed node defines it
if pointed_thing.type == "node" then
local node = minetest.get_node(pointed_thing.under)
if user and not user: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, user, itemstack) or itemstack
end
end
end
local text = itemstack:get_metadata()
local formspec = "size[8,9]"..
"background[-0.5,-0.5;9,10;mcl_books_book_bg.png]"..
@ -23,6 +33,16 @@ local write = function(itemstack, user, pointed_thing)
end
local read = function(itemstack, user, pointed_thing)
-- Call on_rightclick if the pointed node defines it
if pointed_thing.type == "node" then
local node = minetest.get_node(pointed_thing.under)
if user and not user: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, user, itemstack) or itemstack
end
end
end
local meta = minetest.deserialize(itemstack:get_metadata())
local text
if meta ~= nil then

View file

@ -267,6 +267,15 @@ minetest.register_craftitem("mcl_minecarts:minecart", {
if not 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
if mcl_minecarts:is_rail(pointed_thing.under) then
minetest.add_entity(pointed_thing.under, "mcl_minecarts:minecart")
elseif mcl_minecarts:is_rail(pointed_thing.above) then