From fdb23334935ec58af95a6e44baf6af7cb9364965 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Fri, 10 Feb 2023 10:39:43 +0000 Subject: [PATCH] Make placed leaves always become player leaves Any players which still have leaves in their inventory from before this update would have had those leaves rot if someone were to break any log withing 6 nodes of the leaves if they were placed. This commit adds an `after_place_node` callback which makes sure that any leaves placed by the player, become non-rotting player leaves. --- mods/ITEMS/mcl_core/nodes_trees.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_core/nodes_trees.lua b/mods/ITEMS/mcl_core/nodes_trees.lua index 343d9a7a3..cf966425e 100644 --- a/mods/ITEMS/mcl_core/nodes_trees.lua +++ b/mods/ITEMS/mcl_core/nodes_trees.lua @@ -44,6 +44,14 @@ function mcl_core.update_leaves(pos, oldnode) end end +function mcl_core.make_player_leaves(pos) + local node = minetest.get_node(pos) + if minetest.get_item_group(node.name, "player_leaves") ~= 1 then + local playerleafname = node.name .. "_player" + minetest.set_node(pos, {name = playerleafname}) + end +end + -- Register tree trunk (wood) and bark local function register_tree_trunk(subname, description_trunk, description_bark, longdesc, tile_inner, tile_bark, stripped_variant) minetest.register_node("mcl_core:"..subname, { @@ -207,10 +215,13 @@ local function register_leaves(subname, description, longdesc, tiles, color, par minetest.swap_node(pos, new_node) end end + end, + after_place_node = function(pos) + mcl_core.make_player_leaves(pos) -- Leaves placed by the player should always be player leaves. end, } - minetest.register_node("mcl_core:player" .. subname, pl_def) + minetest.register_node("mcl_core:" .. subname .. "_player", pl_def) local l_def = table.copy(pl_def) l_def.groups.player_leaves = nil