make unsupported leaves die & fall.
leaves that aren't in contact with living logs, or are not in contact with any supported leaves, or are too far away from living logs, will now die and fall down.
This commit is contained in:
parent
3459e94de8
commit
f31940ffa5
2 changed files with 26 additions and 5 deletions
|
@ -1,9 +1,26 @@
|
||||||
local modname = minetest.get_current_modname()
|
local modname = minetest.get_current_modname()
|
||||||
|
|
||||||
local function leaves_fall_check (pos, node)
|
local function leaves_fall_check (pos, node)
|
||||||
return blockgame.every(blockgame.vector.get_neighbors(pos), function (pos)
|
local is_supported = false
|
||||||
return minetest.get_item_group(minetest.get_node(pos).name, "supports_leaves") == 0
|
|
||||||
end)
|
blockgame.flood_fill(pos, function (pos, distance)
|
||||||
|
local nodename = minetest.get_node(pos).name
|
||||||
|
|
||||||
|
if blockgame.item_matches(nodename, {"group:supports_leaves"}) then
|
||||||
|
is_supported = true
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if blockgame.item_matches(nodename, {"group:extends_leaves_support"}) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end, 3)
|
||||||
|
|
||||||
|
if not is_supported then
|
||||||
|
minetest.set_node(pos, {name = modname .. ":leaves"})
|
||||||
|
end
|
||||||
|
|
||||||
|
return not is_supported
|
||||||
end
|
end
|
||||||
|
|
||||||
local function reg_leaves (name, def)
|
local function reg_leaves (name, def)
|
||||||
|
@ -17,7 +34,7 @@ local function reg_leaves (name, def)
|
||||||
|
|
||||||
def.groups = blockgame.underride(def.groups, {
|
def.groups = blockgame.underride(def.groups, {
|
||||||
planty = 1,
|
planty = 1,
|
||||||
supports_leaves = 1,
|
extends_leaves_support = 1,
|
||||||
air_flowable = 1,
|
air_flowable = 1,
|
||||||
can_fall = 1,
|
can_fall = 1,
|
||||||
})
|
})
|
||||||
|
|
|
@ -20,7 +20,11 @@ local function reg_log (name, def)
|
||||||
blockgame.register_node(modname .. ":" .. name, def)
|
blockgame.register_node(modname .. ":" .. name, def)
|
||||||
end
|
end
|
||||||
|
|
||||||
reg_log("log")
|
reg_log("log", {
|
||||||
|
groups = {
|
||||||
|
supports_leaves = 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
reg_log("log_alive", {
|
reg_log("log_alive", {
|
||||||
groups = {
|
groups = {
|
||||||
planty = 1,
|
planty = 1,
|
||||||
|
|
Loading…
Reference in a new issue