Change leaf decay to use groups

This commit is contained in:
Aaron Suen 2023-01-14 11:49:36 -05:00
parent 79128f1c27
commit 5bc651e067
4 changed files with 14 additions and 13 deletions

View File

@ -82,6 +82,8 @@ local groups = {
is_stack_only = "(specific) a bare item stack as a node",
lava = "(specific) source or flowing pumwater",
leaf_decay = "decays into its leaf_decay_as items if not connected to tree trunk",
leaf_decay_support = "nodes that stop leaves from decaying (tree trunks)",
leaf_decay_transmit = "nodes that transmit leaf decay stoppage through them (leaves)",
leafy = "(deprecated) loose leaves",
lens_glow_start = "(specific) glowing lenses in warm-up state",
lode_cobble = "(specific) lode cobble or loose lode cobble",

View File

@ -112,7 +112,8 @@ minetest.register_node(modname .. ":tree_bud", {
flammable = 12,
fire_fuel = 6,
falling_node = 1,
scaling_time = 80
scaling_time = 80,
leaf_decay_support = 1
},
crush_damage = 1,
sounds = nodecore.sounds("nc_tree_woody"),
@ -137,7 +138,8 @@ minetest.register_node(modname .. ":leaves_bud", {
fire_fuel = 2,
green = 4,
scaling_time = 90,
leaf_decay = 1
leaf_decay = 1,
leaf_decay_transmit = 1
},
treeable_to = true,
drop = "",

View File

@ -5,8 +5,6 @@ local math_random
= math.random
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
local hashpos = minetest.hash_node_position
local queue = {}
@ -73,15 +71,15 @@ end
local cache = {}
local leaf_decay_support = nodecore.group_expand("group:leaf_decay_support", true)
local leaf_decay_transmit = nodecore.group_expand("group:leaf_decay_transmit", true)
local function check_decay(pos, node)
local hash = hashpos(pos)
local found = cache[hash]
if found and minetest.get_node(found).name == found.name then return true end
return nodecore.scan_flood(pos, 5, function(p)
local n = minetest.get_node(p).name
if n == modname .. ":tree"
or n == modname .. ":tree_bud"
or n == "ignore" then
if n == "ignore" or leaf_decay_support[n] then
while p.prev do
p.name = minetest.get_node(p).name
cache[hashpos(p.prev)] = p
@ -89,10 +87,7 @@ local function check_decay(pos, node)
end
return true
end
if n == modname .. ":leaves"
or n == modname .. ":leaves_bud" then
return
end
if leaf_decay_transmit[n] then return end
return false
end
) or nodecore.leaf_decay(pos, node)

View File

@ -55,7 +55,8 @@ minetest.register_node(modname .. ":tree", {
fire_fuel = 6,
log = 1,
falling_node = 1,
scaling_time = 80
scaling_time = 80,
leaf_decay_support = 1
},
crush_damage = 1,
sounds = nodecore.sounds("nc_tree_woody"),
@ -95,7 +96,8 @@ minetest.register_node(modname .. ":leaves", {
fire_fuel = 2,
green = 3,
scaling_time = 90,
leaf_decay = 1
leaf_decay = 1,
leaf_decay_transmit = 1
},
alternate_loose = {
tiles = {fade(modname .. "_leaves_dry.png")},