diff --git a/mcl_copper_stuff/tools.lua b/mcl_copper_stuff/tools.lua index db0acb1..53ee03b 100644 --- a/mcl_copper_stuff/tools.lua +++ b/mcl_copper_stuff/tools.lua @@ -8,6 +8,8 @@ local axe_longdesc = S("An axe is your tool of choice to cut down trees, wood-ba local sword_longdesc = S("Swords are great in melee combat, as they are fast, deal high damage and can endure countless battles. Swords can also be used to cut down a few particular blocks, such as cobwebs.") local shovel_longdesc = S("Shovels are tools for digging coarse blocks, such as dirt, sand and gravel. They can also be used to turn grass blocks to grass paths. Shovels can be used as weapons, but they are very weak.") local shovel_use = S("To turn a grass block into a grass path, hold the shovel in your hand, then use (rightclick) the top or side of a grass block. This only works when there's air above the grass block.") +local shears_longdesc = S("Shears are tools to shear sheep and to mine a few block types. Shears are a special mining tool and can be used to obtain the original item from grass, leaves and similar blocks that require cutting.") +local shears_use = S("To shear sheep or carve faceless pumpkins, use the “place” key on them. Faces can only be carved at the side of faceless pumpkins. Mining works as usual, but the drops are different for a few blocks.") local wield_scale = mcl_vars.tool_wield_scale @@ -169,6 +171,63 @@ minetest.register_tool("mcl_copper_stuff:sword", { }, }) +-- Shears Carving Function +local carve_pumpkin +if minetest.get_modpath("mcl_farming") then + function carve_pumpkin(itemstack, placer, pointed_thing) + -- Use pointed node's on_rightclick function first, if present + 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 + + -- Only carve pumpkin if used on side + if pointed_thing.above.y ~= pointed_thing.under.y then + return + end + if node.name == "mcl_farming:pumpkin" then + if not minetest.is_creative_enabled(placer:get_player_name()) then + -- Add wear (as if digging a shearsy node) + local toolname = itemstack:get_name() + local wear = mcl_autogroup.get_wear(toolname, "shearsy") + itemstack:add_wear(wear) + end + minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = pointed_thing.above}, true) + local dir = vector.subtract(pointed_thing.under, pointed_thing.above) + local param2 = minetest.dir_to_facedir(dir) + minetest.set_node(pointed_thing.under, {name="mcl_farming:pumpkin_face", param2 = param2}) + minetest.add_item(pointed_thing.above, "mcl_farming:pumpkin_seeds 4") + end + return itemstack + end +end + + +-- Copper shears +minetest.register_tool("mcl_copper_stuff:shears", { + description = S("Copper Shears"), + _doc_items_longdesc = shears_longdesc, + _doc_items_usagehelp = shears_use, + inventory_image = "default_tool_coppershears.png", + wield_image = "default_tool_coppershears.png", + stack_max = 1, + groups = { tool=1, shears=1, dig_speed_class=4, }, + tool_capabilities = { + full_punch_interval = 0.5, + max_drop_level=1, + }, + on_place = carve_pumpkin, + sound = { breaks = "default_tool_breaks" }, + _mcl_toollike_wield = true, + _mcl_diggroups = { + shearsy = { speed = 1.5, level = 1, uses = 119 }, + shearsy_wool = { speed = 3, level = 1, uses = 119 }, + shearsy_cobweb = { speed = 10, level = 1, uses = 119 } + }, +}) + -- Registering crafts minetest.register_craft({ output = "mcl_copper_stuff:pick", @@ -204,4 +263,12 @@ minetest.register_craft({ {"mcl_copper:copper_ingot"}, {"mcl_core:stick"}, } +}) + +minetest.register_craft({ + output = "mcl_copper_stuff:shears", + recipe = { + { "", "mcl_copper:copper_ingot" }, + { "mcl_copper:copper_ingot", "" }, + } }) \ No newline at end of file