diff --git a/mods/bg_tree/decompose.lua b/mods/bg_tree/decompose.lua index cd5bcd2..66adf0c 100644 --- a/mods/bg_tree/decompose.lua +++ b/mods/bg_tree/decompose.lua @@ -48,29 +48,11 @@ blockgame.register_increasing_abm({ rate = function (pos, node, data) local score = 20 - local source_pos = pos - blockgame.flood_fill(pos, function (pos, distance) - if pos == source_pos then return true end + local bonus = blockgame.score_nearby_nodes(pos, 4, decompose_scores, function (gain, distance) + return math.floor(gain / (distance ^ 3)) + end) - local name = minetest.get_node(pos).name - - local gain = 0 - for group, value in pairs(decompose_scores) do - local group = minetest.get_item_group(name, group) - if group > 0 then - gain = math.max(gain, value * group) - end - end - - gain = math.floor(gain / (distance ^ 3)) - - if gain > 0 then - score = score + gain - return true - end - - return false - end, 4) + score = score + bonus return data.value + score end,