Call on_rightclick when clicking a node with fishing rod

This commit is contained in:
Elias Fleckenstein 2021-01-04 20:23:14 +01:00
parent cfc86bcf3d
commit b0b23b7532

View File

@ -25,7 +25,17 @@ local bobber_ENTITY={
objtype="fishing", objtype="fishing",
} }
local fish = function(itemstack, player) local fish = function(itemstack, player, pointed_thing)
if pointed_thing and pointed_thing.type == "node" then
-- Call on_rightclick if the pointed node defines it
local node = minetest.get_node(pointed_thing.under)
if player and not player: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, player, itemstack) or itemstack
end
end
end
local pos = player:get_pos() local pos = player:get_pos()
local objs = minetest.get_objects_inside_radius(pos, 125) local objs = minetest.get_objects_inside_radius(pos, 125)