2021-05-29 17:12:33 +03:00
local S = minetest.get_translator ( minetest.get_current_modname ( ) )
2019-03-08 02:00:09 +03:00
2015-07-03 07:57:09 +03:00
local function create_soil ( pos , inv )
2015-06-29 20:55:56 +03:00
if pos == nil then
return false
end
2017-01-05 03:28:43 +03:00
local node = minetest.get_node ( pos )
2015-06-29 20:55:56 +03:00
local name = node.name
2017-01-05 03:28:43 +03:00
local above = minetest.get_node ( { x = pos.x , y = pos.y + 1 , z = pos.z } )
2017-01-10 06:01:53 +03:00
if minetest.get_item_group ( name , " cultivatable " ) == 2 then
2015-06-29 20:55:56 +03:00
if above.name == " air " then
2017-01-31 14:35:59 +03:00
node.name = " mcl_farming:soil "
2017-01-05 03:28:43 +03:00
minetest.set_node ( pos , node )
2020-04-07 01:55:45 +03:00
minetest.sound_play ( " default_dig_crumbly " , { pos = pos , gain = 0.5 } , true )
2017-01-05 03:28:43 +03:00
return true
end
2017-01-10 06:01:53 +03:00
elseif minetest.get_item_group ( name , " cultivatable " ) == 1 then
2017-01-05 03:28:43 +03:00
if above.name == " air " then
2017-02-01 01:32:56 +03:00
node.name = " mcl_core:dirt "
2017-01-05 03:28:43 +03:00
minetest.set_node ( pos , node )
2020-04-07 01:55:45 +03:00
minetest.sound_play ( " default_dig_crumbly " , { pos = pos , gain = 0.6 } , true )
2015-06-29 20:55:56 +03:00
return true
end
end
return false
end
2019-03-27 15:07:33 +03:00
local hoe_on_place_function = function ( wear_divisor )
return function ( itemstack , user , pointed_thing )
2017-03-02 20:57:22 +03:00
-- 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
2019-03-27 15:07:33 +03:00
if minetest.is_protected ( pointed_thing.under , user : get_player_name ( ) ) then
minetest.record_protection_violation ( pointed_thing.under , user : get_player_name ( ) )
return itemstack
end
2015-07-03 07:57:09 +03:00
if create_soil ( pointed_thing.under , user : get_inventory ( ) ) then
2020-07-10 17:08:40 +03:00
if not minetest.is_creative_enabled ( user : get_player_name ( ) ) then
2019-03-27 15:07:33 +03:00
itemstack : add_wear ( 65535 / wear_divisor )
2015-06-29 20:55:56 +03:00
end
return itemstack
end
2019-03-27 15:07:33 +03:00
end
end
2020-02-19 17:53:51 +03:00
local uses = {
wood = 60 ,
stone = 132 ,
iron = 251 ,
gold = 33 ,
2020-02-19 06:54:17 +03:00
diamond = 1562 ,
2020-02-19 17:53:51 +03:00
}
2020-02-19 06:54:17 +03:00
local hoe_tt = S ( " Turns block into farmland " )
2019-03-27 15:07:33 +03:00
local hoe_longdesc = S ( " Hoes are essential tools for growing crops. They are used to create farmland in order to plant seeds on it. Hoes can also be used as very weak weapons in a pinch. " )
local hoe_usagehelp = S ( " Use the hoe on a cultivatable block (by rightclicking it) to turn it into farmland. Dirt, grass blocks and grass paths are cultivatable blocks. Using a hoe on coarse dirt turns it into dirt. " )
minetest.register_tool ( " mcl_farming:hoe_wood " , {
description = S ( " Wood Hoe " ) ,
2020-02-19 06:54:17 +03:00
_tt_help = hoe_tt .. " \n " .. S ( " Uses: @1 " , uses.wood ) ,
2019-03-27 15:07:33 +03:00
_doc_items_longdesc = hoe_longdesc ,
_doc_items_usagehelp = hoe_usagehelp ,
_doc_items_hidden = false ,
inventory_image = " farming_tool_woodhoe.png " ,
2021-04-05 15:32:48 +03:00
wield_scale = mcl_vars.tool_wield_scale ,
2020-02-19 17:53:51 +03:00
on_place = hoe_on_place_function ( uses.wood ) ,
2020-11-25 14:47:27 +03:00
groups = { tool = 1 , hoe = 1 , enchantability = 15 } ,
2017-01-17 02:44:37 +03:00
tool_capabilities = {
full_punch_interval = 1 ,
2020-02-19 17:53:51 +03:00
damage_groups = { fleshy = 1 , } ,
punch_attack_uses = uses.wood ,
2017-01-17 02:44:37 +03:00
} ,
2018-02-02 04:33:10 +03:00
_repair_material = " group:wood " ,
2021-02-18 11:28:12 +03:00
_mcl_toollike_wield = true ,
2021-04-12 16:09:48 +03:00
_mcl_diggroups = {
hoey = { speed = 2 , level = 1 , uses = 60 }
} ,
2015-06-29 20:55:56 +03:00
} )
minetest.register_craft ( {
2017-01-31 14:35:59 +03:00
output = " mcl_farming:hoe_wood " ,
2015-06-29 20:55:56 +03:00
recipe = {
2017-01-05 06:39:36 +03:00
{ " group:wood " , " group:wood " } ,
2017-02-01 01:32:56 +03:00
{ " " , " mcl_core:stick " } ,
{ " " , " mcl_core:stick " }
2015-06-29 20:55:56 +03:00
}
} )
2017-01-10 03:59:21 +03:00
minetest.register_craft ( {
2017-01-31 14:35:59 +03:00
output = " mcl_farming:hoe_wood " ,
2017-01-10 03:59:21 +03:00
recipe = {
{ " group:wood " , " group:wood " } ,
2017-02-01 01:32:56 +03:00
{ " mcl_core:stick " , " " } ,
{ " mcl_core:stick " , " " }
2017-01-10 03:59:21 +03:00
}
} )
2017-01-10 08:43:07 +03:00
minetest.register_craft ( {
type = " fuel " ,
2017-01-31 14:35:59 +03:00
recipe = " mcl_farming:hoe_wood " ,
2017-01-10 08:43:07 +03:00
burntime = 10 ,
} )
2015-06-29 20:55:56 +03:00
2017-01-31 14:35:59 +03:00
minetest.register_tool ( " mcl_farming:hoe_stone " , {
2019-03-08 02:00:09 +03:00
description = S ( " Stone Hoe " ) ,
2020-02-19 06:54:17 +03:00
_tt_help = hoe_tt .. " \n " .. S ( " Uses: @1 " , uses.stone ) ,
2017-03-12 03:55:18 +03:00
_doc_items_longdesc = hoe_longdesc ,
_doc_items_usagehelp = hoe_usagehelp ,
2015-06-29 20:55:56 +03:00
inventory_image = " farming_tool_stonehoe.png " ,
2021-04-05 15:32:48 +03:00
wield_scale = mcl_vars.tool_wield_scale ,
2020-02-19 17:53:51 +03:00
on_place = hoe_on_place_function ( uses.stone ) ,
2020-11-25 14:47:27 +03:00
groups = { tool = 1 , hoe = 1 , enchantability = 5 } ,
2017-01-17 02:44:37 +03:00
tool_capabilities = {
full_punch_interval = 0.5 ,
2020-02-19 17:53:51 +03:00
damage_groups = { fleshy = 1 , } ,
punch_attack_uses = uses.stone ,
2017-01-17 02:44:37 +03:00
} ,
2021-02-12 19:13:58 +03:00
_repair_material = " mcl_core:cobble " ,
2021-02-18 11:28:12 +03:00
_mcl_toollike_wield = true ,
2021-04-12 16:09:48 +03:00
_mcl_diggroups = {
hoey = { speed = 4 , level = 3 , uses = 132 }
} ,
2015-06-29 20:55:56 +03:00
} )
minetest.register_craft ( {
2017-01-31 14:35:59 +03:00
output = " mcl_farming:hoe_stone " ,
2015-06-29 20:55:56 +03:00
recipe = {
2017-02-01 01:32:56 +03:00
{ " mcl_core:cobble " , " mcl_core:cobble " } ,
{ " " , " mcl_core:stick " } ,
{ " " , " mcl_core:stick " }
2015-06-29 20:55:56 +03:00
}
} )
2017-01-10 03:59:21 +03:00
minetest.register_craft ( {
2017-01-31 14:35:59 +03:00
output = " mcl_farming:hoe_stone " ,
2017-01-10 03:59:21 +03:00
recipe = {
2017-02-01 01:32:56 +03:00
{ " mcl_core:cobble " , " mcl_core:cobble " } ,
{ " mcl_core:stick " , " " } ,
{ " mcl_core:stick " , " " }
2017-01-10 03:59:21 +03:00
}
} )
2015-06-29 20:55:56 +03:00
2017-02-11 23:14:40 +03:00
minetest.register_tool ( " mcl_farming:hoe_iron " , {
2019-03-08 02:00:09 +03:00
description = S ( " Iron Hoe " ) ,
2020-02-19 06:54:17 +03:00
_tt_help = hoe_tt .. " \n " .. S ( " Uses: @1 " , uses.iron ) ,
2017-03-12 03:55:18 +03:00
_doc_items_longdesc = hoe_longdesc ,
_doc_items_usagehelp = hoe_usagehelp ,
2015-06-29 20:55:56 +03:00
inventory_image = " farming_tool_steelhoe.png " ,
2021-04-05 15:32:48 +03:00
wield_scale = mcl_vars.tool_wield_scale ,
2020-02-19 17:53:51 +03:00
on_place = hoe_on_place_function ( uses.iron ) ,
2020-11-25 14:47:27 +03:00
groups = { tool = 1 , hoe = 1 , enchantability = 14 } ,
2017-01-17 02:44:37 +03:00
tool_capabilities = {
-- 1/3
full_punch_interval = 0.33333333 ,
2020-02-19 17:53:51 +03:00
damage_groups = { fleshy = 1 , } ,
punch_attack_uses = uses.iron ,
2017-01-17 02:44:37 +03:00
} ,
2018-02-02 04:33:10 +03:00
_repair_material = " mcl_core:iron_ingot " ,
2021-02-18 11:28:12 +03:00
_mcl_toollike_wield = true ,
2021-04-12 16:09:48 +03:00
_mcl_diggroups = {
hoey = { speed = 6 , level = 4 , uses = 251 }
} ,
2015-06-29 20:55:56 +03:00
} )
minetest.register_craft ( {
2017-02-11 23:14:40 +03:00
output = " mcl_farming:hoe_iron " ,
2015-06-29 20:55:56 +03:00
recipe = {
2017-02-11 23:14:40 +03:00
{ " mcl_core:iron_ingot " , " mcl_core:iron_ingot " } ,
2017-02-01 01:32:56 +03:00
{ " " , " mcl_core:stick " } ,
{ " " , " mcl_core:stick " }
2015-06-29 20:55:56 +03:00
}
} )
2017-01-10 03:59:21 +03:00
minetest.register_craft ( {
2017-02-11 23:14:40 +03:00
output = " mcl_farming:hoe_iron " ,
2017-01-10 03:59:21 +03:00
recipe = {
2017-02-11 23:14:40 +03:00
{ " mcl_core:iron_ingot " , " mcl_core:iron_ingot " } ,
2017-02-01 01:32:56 +03:00
{ " mcl_core:stick " , " " } ,
{ " mcl_core:stick " , " " }
2017-01-10 03:59:21 +03:00
}
} )
2015-06-29 20:55:56 +03:00
2017-01-04 12:56:38 +03:00
minetest.register_craft ( {
type = " cooking " ,
2017-02-01 01:32:56 +03:00
output = " mcl_core:iron_nugget " ,
2017-02-11 23:14:40 +03:00
recipe = " mcl_farming:hoe_iron " ,
2017-01-04 13:49:05 +03:00
cooktime = 10 ,
2017-01-04 12:56:38 +03:00
} )
2017-01-31 14:35:59 +03:00
minetest.register_tool ( " mcl_farming:hoe_gold " , {
2019-03-08 02:00:09 +03:00
description = S ( " Golden Hoe " ) ,
2020-02-19 06:54:17 +03:00
_tt_help = hoe_tt .. " \n " .. S ( " Uses: @1 " , uses.gold ) ,
2017-03-12 03:55:18 +03:00
_doc_items_longdesc = hoe_longdesc ,
_doc_items_usagehelp = hoe_usagehelp ,
2015-06-29 20:55:56 +03:00
inventory_image = " farming_tool_goldhoe.png " ,
2021-04-05 15:32:48 +03:00
wield_scale = mcl_vars.tool_wield_scale ,
2020-02-19 17:53:51 +03:00
on_place = hoe_on_place_function ( uses.gold ) ,
2020-11-25 14:47:27 +03:00
groups = { tool = 1 , hoe = 1 , enchantability = 22 } ,
2017-01-17 02:44:37 +03:00
tool_capabilities = {
full_punch_interval = 1 ,
2020-02-19 17:53:51 +03:00
damage_groups = { fleshy = 1 , } ,
punch_attack_uses = uses.gold ,
2017-01-17 02:44:37 +03:00
} ,
2018-02-02 04:33:10 +03:00
_repair_material = " mcl_core:gold_ingot " ,
2021-02-18 11:28:12 +03:00
_mcl_toollike_wield = true ,
2021-04-12 16:09:48 +03:00
_mcl_diggroups = {
hoey = { speed = 12 , level = 2 , uses = 33 }
} ,
2015-06-29 20:55:56 +03:00
} )
minetest.register_craft ( {
2017-01-31 14:35:59 +03:00
output = " mcl_farming:hoe_gold " ,
2015-06-29 20:55:56 +03:00
recipe = {
2017-02-01 01:32:56 +03:00
{ " mcl_core:gold_ingot " , " mcl_core:gold_ingot " } ,
{ " " , " mcl_core:stick " } ,
{ " " , " mcl_core:stick " }
2015-06-29 20:55:56 +03:00
}
} )
2017-01-10 03:59:21 +03:00
minetest.register_craft ( {
2017-01-31 14:35:59 +03:00
output = " mcl_farming:hoe_gold " ,
2017-01-10 03:59:21 +03:00
recipe = {
2017-02-01 01:32:56 +03:00
{ " mcl_core:gold_ingot " , " mcl_core:gold_ingot " } ,
{ " mcl_core:stick " , " " } ,
{ " mcl_core:stick " , " " }
2017-01-10 03:59:21 +03:00
}
} )
2015-06-29 20:55:56 +03:00
2017-01-04 12:56:38 +03:00
minetest.register_craft ( {
type = " cooking " ,
2017-02-01 01:32:56 +03:00
output = " mcl_core:gold_nugget " ,
2017-01-31 14:35:59 +03:00
recipe = " mcl_farming:hoe_gold " ,
2017-01-04 13:49:05 +03:00
cooktime = 10 ,
2017-01-04 12:56:38 +03:00
} )
2017-01-31 14:35:59 +03:00
minetest.register_tool ( " mcl_farming:hoe_diamond " , {
2019-03-08 02:00:09 +03:00
description = S ( " Diamond Hoe " ) ,
2020-02-19 06:54:17 +03:00
_tt_help = hoe_tt .. " \n " .. S ( " Uses: @1 " , uses.diamond ) ,
2017-03-12 03:55:18 +03:00
_doc_items_longdesc = hoe_longdesc ,
_doc_items_usagehelp = hoe_usagehelp ,
2015-06-29 20:55:56 +03:00
inventory_image = " farming_tool_diamondhoe.png " ,
2021-04-05 15:32:48 +03:00
wield_scale = mcl_vars.tool_wield_scale ,
2020-02-19 17:53:51 +03:00
on_place = hoe_on_place_function ( uses.diamond ) ,
2020-11-25 14:47:27 +03:00
groups = { tool = 1 , hoe = 1 , enchantability = 10 } ,
2017-01-17 02:44:37 +03:00
tool_capabilities = {
full_punch_interval = 0.25 ,
2020-02-19 17:53:51 +03:00
damage_groups = { fleshy = 1 , } ,
punch_attack_uses = uses.diamond ,
2017-01-17 02:44:37 +03:00
} ,
2018-02-02 04:33:10 +03:00
_repair_material = " mcl_core:diamond " ,
2021-02-18 11:28:12 +03:00
_mcl_toollike_wield = true ,
2021-04-12 16:09:48 +03:00
_mcl_diggroups = {
hoey = { speed = 8 , level = 5 , uses = 1562 }
} ,
2015-06-29 20:55:56 +03:00
} )
minetest.register_craft ( {
2017-01-31 14:35:59 +03:00
output = " mcl_farming:hoe_diamond " ,
2015-06-29 20:55:56 +03:00
recipe = {
2017-02-01 01:32:56 +03:00
{ " mcl_core:diamond " , " mcl_core:diamond " } ,
{ " " , " mcl_core:stick " } ,
{ " " , " mcl_core:stick " }
2015-06-29 20:55:56 +03:00
}
} )
2017-01-10 03:59:21 +03:00
minetest.register_craft ( {
2017-01-31 14:35:59 +03:00
output = " mcl_farming:hoe_diamond " ,
2017-01-10 03:59:21 +03:00
recipe = {
2017-02-01 01:32:56 +03:00
{ " mcl_core:diamond " , " mcl_core:diamond " } ,
{ " mcl_core:stick " , " " } ,
{ " mcl_core:stick " , " " }
2017-01-10 03:59:21 +03:00
}
} )