From 681a9aa8c68c7436102544fccf93787acd812a84 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 2 Mar 2017 18:57:22 +0100 Subject: [PATCH] Allow to place hoes into itemframes --- mods/ITEMS/mcl_farming/hoes.lua | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/mods/ITEMS/mcl_farming/hoes.lua b/mods/ITEMS/mcl_farming/hoes.lua index c176e022e2..40201afaa4 100644 --- a/mods/ITEMS/mcl_farming/hoes.lua +++ b/mods/ITEMS/mcl_farming/hoes.lua @@ -25,6 +25,14 @@ minetest.register_tool("mcl_farming:hoe_wood", { description = "Wood Hoe", inventory_image = "farming_tool_woodhoe.png", on_place = function(itemstack, user, pointed_thing) + -- Call on_rightclick if the pointed node defines it + 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 + if create_soil(pointed_thing.under, user:get_inventory()) then if not minetest.setting_getbool("creative_mode") then itemstack:add_wear(65535/60) @@ -65,6 +73,14 @@ minetest.register_tool("mcl_farming:hoe_stone", { description = "Stone Hoe", inventory_image = "farming_tool_stonehoe.png", on_place = function(itemstack, user, pointed_thing) + -- Call on_rightclick if the pointed node defines it + 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 + if create_soil(pointed_thing.under, user:get_inventory()) then if not minetest.setting_getbool("creative_mode") then itemstack:add_wear(65535/132) @@ -100,6 +116,14 @@ minetest.register_tool("mcl_farming:hoe_iron", { description = "Iron Hoe", inventory_image = "farming_tool_steelhoe.png", on_place = function(itemstack, user, pointed_thing) + -- Call on_rightclick if the pointed node defines it + 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 + if create_soil(pointed_thing.under, user:get_inventory()) then if not minetest.setting_getbool("creative_mode") then itemstack:add_wear(65535/251) @@ -143,6 +167,14 @@ minetest.register_tool("mcl_farming:hoe_gold", { description = "Golden Hoe", inventory_image = "farming_tool_goldhoe.png", on_place = function(itemstack, user, pointed_thing) + -- Call on_rightclick if the pointed node defines it + 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 + if create_soil(pointed_thing.under, user:get_inventory()) then if not minetest.setting_getbool("creative_mode") then itemstack:add_wear(65535/33) @@ -187,6 +219,14 @@ minetest.register_tool("mcl_farming:hoe_diamond", { description = "Diamond Hoe", inventory_image = "farming_tool_diamondhoe.png", on_place = function(itemstack, user, pointed_thing) + -- Call on_rightclick if the pointed node defines it + 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 + if create_soil(pointed_thing.under, user:get_inventory()) then if not minetest.setting_getbool("creative_mode") then itemstack:add_wear(65535/1562)