From 5dff9e199404b89d5e5571620234024f283a9d4f Mon Sep 17 00:00:00 2001 From: Michieal Date: Sun, 5 Feb 2023 18:47:45 -0500 Subject: [PATCH] Fixed the ABM situation so that now bamboo "breaks" when pushed by pistons. Probably not the most elegant, but hey. It works. --- mods/ITEMS/mcl_bamboo/init.lua | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_bamboo/init.lua b/mods/ITEMS/mcl_bamboo/init.lua index fb10903b4..d929a57c6 100644 --- a/mods/ITEMS/mcl_bamboo/init.lua +++ b/mods/ITEMS/mcl_bamboo/init.lua @@ -26,14 +26,42 @@ dofile(minetest.get_modpath(modname) .. "/recipes.lua") --ABMs minetest.register_abm({ + label = "Bamboo Grow", nodenames = mcl_bamboo.bamboo_index, interval = 10, chance = 20, action = function(pos, _) - mcl_bamboo.break_orphaned(pos) mcl_bamboo.grow_bamboo(pos, false) end, }) +minetest.register_abm({ + label = "Break Orphaned Bamboo", + nodenames = mcl_bamboo.bamboo_index, + interval = 1.5, + chance = 1, + action = function(pos, _) + local node_below = minetest.get_node(vector.offset(pos, 0, -1, 0)) + local node_name = node_below.name + + -- short circuit checks. + if mcl_bamboo.is_dirt(node_name) or mcl_bamboo.is_bamboo(node_name) or mcl_bamboo.is_bamboo(minetest.get_node(pos).name) == false then + return + end + + -- dig the node. + minetest.remove_node(pos) -- if that fails, remove the node + local istack = ItemStack("mcl_bamboo:bamboo") + local sound_params = { + pos = pos, + gain = 1.0, -- default + max_hear_distance = 10, -- default, uses a Euclidean metric + } + + minetest.remove_node(pos) + minetest.sound_play(mcl_sounds.node_sound_wood_defaults().dug, sound_params, true) + minetest.add_item(pos, istack) + end, +}) -- Base Aliases. local SCAFFOLDING_NAME = "mcl_bamboo:scaffolding"