From 58c236532d87a635ee42cd7f9d9574c28e65bed3 Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Fri, 1 Feb 2019 15:36:41 +0000 Subject: [PATCH] added mithril scythe as special item --- README.md | 3 +- hoes.lua | 123 ++++++++++++++++++++++++++++ lucky_block.lua | 1 + textures/farming_scythe_mithril.png | Bin 0 -> 172 bytes 4 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 textures/farming_scythe_mithril.png diff --git a/README.md b/README.md index 603e0c8..8f3e671 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ This mod works by adding your new plant to the {growing=1} group and numbering t ### Changelog: +- 1.40 - Added Mithril Scythe to quick harvest and replant crops on right-click. - 1.39 - Added Rice, Rye and Oats thanks to Ademants Grains mod. Added Jaffa Cake and multigrain bread. - 1.38 - Pumpkin grows into block, use chopping board to cut into 4x slices, same with melon block, 2x2 slices makes a block, cocoa pods are no longer walkable - 1.37 - Added custom 'growth_check(pos, nodename) function for crop nodes to use (check cocoa.lua for example) @@ -60,4 +61,4 @@ This mod works by adding your new plant to the {growing=1} group and numbering t - 0.1 - Fixed growing bug - 0.0 - Initial release -### Lucky Blocks: 38 +### Lucky Blocks: 39 diff --git a/hoes.lua b/hoes.lua index 633e6f0..6b38de2 100644 --- a/hoes.lua +++ b/hoes.lua @@ -330,3 +330,126 @@ minetest.register_craftitem("farming:hoe_bomb", { end end, }) + +-- Mithril Scythe (special item) + +minetest.register_tool("farming:scythe_mithril", { + description = S("Mithril Scythe (Right-click crop to harvest and replant)"), + inventory_image = "farming_scythe_mithril.png", + tool_capabilities = { + full_punch_interval = 0.8, + max_drop_level = 2, + groupcaps = { + fleshy = {times = {[2] = 0.65, [3] = 0.25}, uses = 150, maxlevel = 2}, + snappy = {times = {[2] = 0.70, [3] = 0.25}, uses = 150, maxlevel = 2}, + }, + damage_groups = {fleshy = 8}, + }, + sound = {breaks = "default_tool_breaks"}, + + on_place = function(itemstack, placer, pointed_thing) + + if pointed_thing.type ~= "node" then + return + end + + local pos = pointed_thing.under + local name = placer:get_player_name() + + if minetest.is_protected(pos, name) then + return + end + + local node = minetest.get_node_or_nil(pos) + + if not node then + return + end + + local def = minetest.registered_nodes[node.name] + + if not def then + return + end + + if not def.drop then + return + end + + if not def.groups + or not def.groups.plant then + return + end + + local drops = minetest.get_node_drops(node.name, "") + + if not drops + or #drops == 0 + or (#drops == 1 and drops[1] == "") then + return + end + + -- get crop name + local mname = node.name:split(":")[1] + local pname = node.name:split(":")[2] + local sname = tonumber(pname:split("_")[2]) + pname = pname:split("_")[1] + + if not sname then + return + end + + -- add dropped items + for _, dropped_item in pairs(drops) do + + local obj = minetest.add_item(pos, dropped_item) + + if obj then + + obj:set_velocity({ + x = math.random(-10, 10) / 9, + y = 3, + z = math.random(-10, 10) / 9, + }) + end + end + + -- Run script hook + for _, callback in pairs(core.registered_on_dignodes) do + callback(pos, node.name) + end + + -- play sound + minetest.sound_play("default_grass_footstep", {pos = pos, gain = 1.0}) + + local replace = mname .. ":" .. pname .. "_1" + + if minetest.registered_nodes[replace] then + + local p2 = minetest.registered_nodes[replace].place_param2 or 1 + + minetest.set_node(pos, {name = replace, param2 = p2}) + else + minetest.set_node(pos, {name = "air"}) + end + + if not farming.is_creative(name) then + + itemstack:add_wear(65535 / 150) -- 150 uses + + return itemstack + end + end, +}) + +if minetest.get_modpath("moreores") then + + minetest.register_craft({ + output = "farming:scythe_mithril", + recipe = { + {"", "moreores:mithril_ingot", "moreores:mithril_ingot"}, + {"moreores:mithril_ingot", "", "group:stick"}, + {"", "", "group:stick"} + } + }) +end diff --git a/lucky_block.lua b/lucky_block.lua index f8ad0eb..5a69a68 100644 --- a/lucky_block.lua +++ b/lucky_block.lua @@ -34,6 +34,7 @@ if minetest.get_modpath("lucky_block") then {"dro", {"farming:hoe_bomb"}, 10}, {"dro", {"farming:turkish_delight"}, 5}, {"lig"}, + {"dro", {"farming:scythe_mithril"}, 1}, {"sch", "instafarm", 0, true, { {"farming:wheat_8", "farming:carrot_8"}, {"farming:cotton_8", "farming:rhubarb_3"}, diff --git a/textures/farming_scythe_mithril.png b/textures/farming_scythe_mithril.png new file mode 100644 index 0000000000000000000000000000000000000000..17c89c5a38cef3c7af0c5c4cb2449c507c1c0063 GIT binary patch literal 172 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPE^4e$wZ%`eKeQV~#AZVR-Ov9URw z<0;(McE46j{x47gV@Z%-FoVOh8)-m}tEY=&2*>s0goJ>gpd<#yWm`mdKI;Vst0Nk1~bN~PV literal 0 HcmV?d00001