From 3b16a2858f83140601abfc05515529d0bf60ddfa Mon Sep 17 00:00:00 2001 From: Zefram Date: Wed, 13 Aug 2014 23:13:52 +0100 Subject: [PATCH] Revise rules for regenerating latex To ensure that only rubber tree trunk nodes that are part of trees regenerate, rather than those that are used as building blocks, check that they are sufficiently close to rubber tree leaves. This replaces the older rule that naturally-grown trunks regenerate (regardless of leaves) and manually-placed trunks don't (even though manually building a tree otherwise works). The detection of manually-placed trunks was in any case broken for users of moretrees, because that mod fails to set the flag signalling manual placement. Incidentally also fix a bug that caused rubber tree branches (horizontal trunk nodes) to turn vertical when regenerating latex. Rather than set the complete node structure, only switch the type name, as does the tree tap when emptying the node. --- technic/tools/tree_tap.lua | 7 +++---- technic_worldgen/rubber.lua | 8 -------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/technic/tools/tree_tap.lua b/technic/tools/tree_tap.lua index 275f4b6..f4b12bf 100644 --- a/technic/tools/tree_tap.lua +++ b/technic/tools/tree_tap.lua @@ -65,11 +65,10 @@ minetest.register_abm({ interval = 60, chance = 15, action = function(pos, node) - local meta = minetest.get_meta(pos) - if meta:get_int("placed") ~= 0 then - return + if minetest.find_node_near(pos, (moretrees and moretrees.leafdecay_radius) or 5, {"moretrees:rubber_tree_leaves"}) then + node.name = "moretrees:rubber_tree_trunk" + minetest.swap_node(pos, node) end - minetest.set_node(pos, {name="moretrees:rubber_tree_trunk"}) end }) diff --git a/technic_worldgen/rubber.lua b/technic_worldgen/rubber.lua index f04be84..93b6d66 100644 --- a/technic_worldgen/rubber.lua +++ b/technic_worldgen/rubber.lua @@ -27,10 +27,6 @@ minetest.register_node(":moretrees:rubber_tree_trunk", { groups = {tree=1, snappy=1, choppy=2, oddly_breakable_by_hand=1, flammable=2}, sounds = default.node_sound_wood_defaults(), - after_place_node = function(pos, placer, itemstack) - local meta = minetest.get_meta(pos) - meta:set_int("placed", 1) - end, }) minetest.register_node(":moretrees:rubber_tree_trunk_empty", { @@ -40,10 +36,6 @@ minetest.register_node(":moretrees:rubber_tree_trunk_empty", { groups = {tree=1, snappy=1, choppy=2, oddly_breakable_by_hand=1, flammable=2, not_in_creative_inventory=1}, sounds = default.node_sound_wood_defaults(), - after_place_node = function(pos, placer, itemstack) - local meta = minetest.get_meta(pos) - meta:set_int("placed", 1) - end, }) minetest.register_node(":moretrees:rubber_tree_leaves", { -- 2.30.2