From 54fb702c8f2ee920e316d60aa0e925c1e6b2e83d Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 3 Aug 2017 02:27:55 +0200 Subject: [PATCH] Shears selfdrop dead bush, tall grass, fern, vine, leaves --- mods/ENTITIES/mcl_item_entity/init.lua | 15 +++++++++++++++ mods/ITEMS/mcl_core/nodes_climb.lua | 7 +------ mods/ITEMS/mcl_core/nodes_misc.lua | 3 ++- mods/ITEMS/mcl_core/nodes_trees.lua | 1 + mods/ITEMS/mcl_flowers/init.lua | 14 ++------------ 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 8e8cdf47c2..f4205ff3c1 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -217,6 +217,21 @@ function minetest.handle_node_drops(pos, drops, digger) return end + --[[ Special node drops when dug by shears by reading _mcl_shears_drop + from the node definition. + Definition of _mcl_shears_drop: + * true: Drop itself when dug by shears + * table: Drop every itemstring in this table when dub by shears + ]] + local nodedef = minetest.registered_nodes[dug_node.name] + if toolcaps.groupcaps and toolcaps.groupcaps.shearsy_dig and nodedef._mcl_shears_drop then + if nodedef._mcl_shears_drop == true then + drops = { dug_node.name } + else + drops = nodedef._mcl_shears_drop + end + end + for _,item in ipairs(drops) do local count, name if type(item) == "string" then diff --git a/mods/ITEMS/mcl_core/nodes_climb.lua b/mods/ITEMS/mcl_core/nodes_climb.lua index 5ecb93515c..4fa3adeb47 100644 --- a/mods/ITEMS/mcl_core/nodes_climb.lua +++ b/mods/ITEMS/mcl_core/nodes_climb.lua @@ -95,12 +95,7 @@ minetest.register_node("mcl_core:vine", { groups = {handy=1,axey=1,shearsy=1,swordy=1, flammable=2,deco_block=1,destroy_by_lava_flow=1,dig_by_piston=1}, sounds = mcl_sounds.node_sound_leaves_defaults(), drop = "", - after_dig_node = function(pos, oldnode, oldmetadata, user) - local item = user:get_wielded_item() - if item:get_name() == "mcl_tools:shears" then - minetest.add_item(pos, oldnode.name) - end - end, + _mcl_shears_drop = true, node_placement_prediction = "", -- Restrict placement of vines on_place = function(itemstack, placer, pointed_thing) diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index 36e44e757a..a02ccd752a 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -98,6 +98,7 @@ minetest.register_node("mcl_core:deadbush", { }, } }, + _mcl_shears_drop = true, sounds = mcl_sounds.node_sound_leaves_defaults(), selection_box = { type = "fixed", @@ -162,4 +163,4 @@ minetest.register_node("mcl_core:void", { -- Infinite blast resistance; it should never be destroyed by explosions _mcl_blast_resistance = -1, _mcl_hardness = -1, -}) \ No newline at end of file +}) diff --git a/mods/ITEMS/mcl_core/nodes_trees.lua b/mods/ITEMS/mcl_core/nodes_trees.lua index cc0070bb13..7dd29b0b13 100644 --- a/mods/ITEMS/mcl_core/nodes_trees.lua +++ b/mods/ITEMS/mcl_core/nodes_trees.lua @@ -72,6 +72,7 @@ local register_leaves = function(subname, description, longdesc, tiles, drop1, d stack_max = 64, groups = {handy=1,shearsy=1,swordy=1, leafdecay=4, flammable=2, leaves=1, deco_block=1, dig_by_piston=1}, drop = drop, + _mcl_shears_drop = true, sounds = mcl_sounds.node_sound_leaves_defaults(), _mcl_blast_resistance = 1, _mcl_hardness = 0.2, diff --git a/mods/ITEMS/mcl_flowers/init.lua b/mods/ITEMS/mcl_flowers/init.lua index 23d4315b87..2b11a543d1 100644 --- a/mods/ITEMS/mcl_flowers/init.lua +++ b/mods/ITEMS/mcl_flowers/init.lua @@ -95,14 +95,9 @@ minetest.register_node("mcl_flowers:tallgrass", { groups = {dig_immediate=3, flammable=3,attached_node=1,plant=1,place_flowerlike=1,non_mycelium_plant=1,dig_by_water=1,destroy_by_lava_flow=1,deco_block=1}, sounds = mcl_sounds.node_sound_leaves_defaults(), drop = wheat_seed_drop, + _mcl_shears_drop = true, node_placement_prediction = "", on_place = on_place_flower, - after_dig_node = function(pos, oldnode, oldmetadata, user) - local item = user:get_wielded_item() - if item:get_name() == "mcl_tools:shears" then - minetest.add_item(pos, oldnode.name) - end - end, _mcl_blast_resistance = 0, _mcl_hardness = 0, }) @@ -125,13 +120,8 @@ minetest.register_node("mcl_flowers:fern", { sounds = mcl_sounds.node_sound_leaves_defaults(), node_placement_prediction = "", on_place = on_place_flower, - after_dig_node = function(pos, oldnode, oldmetadata, user) - local item = user:get_wielded_item() - if item:get_name() == "mcl_tools:shears" then - minetest.add_item(pos, oldnode.name) - end - end, drop = wheat_seed_drop, + _mcl_shears_drop = true, selection_box = { type = "fixed", fixed = { -4/16, -0.5, -4/16, 4/16, 7/16, 4/16 },