From c5ec3c770c4e24c119907c23ee28fcfc21724bda Mon Sep 17 00:00:00 2001 From: cora Date: Wed, 16 Nov 2022 02:58:15 +0100 Subject: [PATCH 1/3] Sweet berries: Add rightclick harvesting --- mods/ITEMS/mcl_farming/sweet_berry.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mods/ITEMS/mcl_farming/sweet_berry.lua b/mods/ITEMS/mcl_farming/sweet_berry.lua index f87220d90..2d1bbb992 100644 --- a/mods/ITEMS/mcl_farming/sweet_berry.lua +++ b/mods/ITEMS/mcl_farming/sweet_berry.lua @@ -35,6 +35,20 @@ for i=0, 3 do sounds = mcl_sounds.node_sound_leaves_defaults(), _mcl_blast_resistance = 0, _mcl_hardness = 0, + on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + local stage + if node.name:find("_2") then + stage = 2 + elseif node.name:find("_3") then + stage = 3 + end + if stage then + for i=1,math.random(stage) do + minetest.add_item(pos,"mcl_farming:sweet_berry") + end + minetest.swap_node(pos,{name = "mcl_farming:sweet_berry_bush_" .. stage - 1 }) + end + end, }) minetest.register_alias("mcl_sweet_berry:sweet_berry_bush_" .. i, node_name) end From 328a377940b38bc3791c3afd5fe784ed07a4889c Mon Sep 17 00:00:00 2001 From: cora Date: Wed, 16 Nov 2022 17:24:05 +0100 Subject: [PATCH 2/3] export apply_bone_meal function in mcl_dye this is essentially just a hack to not put any more sweetberry code in mcl_dye because the architecture makes it necessary for mcl_dye to depend on mcl_farming, not the other way around - hence all the plant bonemealing is done in mcl_dye... --- mods/ITEMS/mcl_dye/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mods/ITEMS/mcl_dye/init.lua b/mods/ITEMS/mcl_dye/init.lua index 73884856a..8296519ca 100644 --- a/mods/ITEMS/mcl_dye/init.lua +++ b/mods/ITEMS/mcl_dye/init.lua @@ -379,6 +379,8 @@ local function apply_bone_meal(pointed_thing,user) return false end +mcl_dye.apply_bone_meal = apply_bone_meal + minetest.register_craftitem("mcl_dye:white", { inventory_image = "mcl_dye_white.png", description = S("Bone Meal"), From 142f3d6d5a5e4ee93245c4de051eab3d052d02c5 Mon Sep 17 00:00:00 2001 From: cora Date: Wed, 16 Nov 2022 17:25:38 +0100 Subject: [PATCH 3/3] Handle bonemealing in the sweetberry on_rightclick --- mods/ITEMS/mcl_farming/sweet_berry.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mods/ITEMS/mcl_farming/sweet_berry.lua b/mods/ITEMS/mcl_farming/sweet_berry.lua index 2d1bbb992..69ac552e5 100644 --- a/mods/ITEMS/mcl_farming/sweet_berry.lua +++ b/mods/ITEMS/mcl_farming/sweet_berry.lua @@ -36,6 +36,10 @@ for i=0, 3 do _mcl_blast_resistance = 0, _mcl_hardness = 0, on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + if mcl_dye and clicker:get_wielded_item():get_name() == "mcl_dye:white" then + mcl_dye.apply_bone_meal({under=pos},clicker) + return + end local stage if node.name:find("_2") then stage = 2