make leaves fall down when unsupported.
also refactor leaves registration code.
This commit is contained in:
parent
d884e75a24
commit
31b2242c38
1 changed files with 43 additions and 22 deletions
|
@ -35,32 +35,53 @@ reg_log("sapling", {
|
||||||
drop = modname .. ":log",
|
drop = modname .. ":log",
|
||||||
})
|
})
|
||||||
|
|
||||||
local function reg_leaves (name, desc, drop, texture, groups)
|
|
||||||
groups = groups or {}
|
|
||||||
groups.planty = 1
|
|
||||||
groups.air_flowable = 1
|
|
||||||
|
|
||||||
texture = texture or name
|
|
||||||
|
|
||||||
drop = drop or name
|
local function leaves_fall_check (pos, node)
|
||||||
|
return blockgame.every(blockgame.vector.get_neighbors(pos), function (pos)
|
||||||
blockgame.register_node(modname .. ":" .. name, {
|
return minetest.get_item_group(minetest.get_node(pos).name, "supports_leaves") == 0
|
||||||
description = desc,
|
end)
|
||||||
drawtype = "glasslike",
|
|
||||||
tiles = {
|
|
||||||
modname .. "_" .. texture .. ".png",
|
|
||||||
},
|
|
||||||
paramtype = "light",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
groups = groups,
|
|
||||||
drop = modname .. ":" .. drop,
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
reg_leaves("leaves", "Leaves")
|
local function reg_leaves (name, def)
|
||||||
reg_leaves("leaves_growing", "Growing Leaves", "leaves", "leaves_alive")
|
def.description = def.description or name
|
||||||
reg_leaves("leaves_alive", "Leaves", "leaves")
|
def.texture = def.texture or name
|
||||||
reg_leaves("leaves_decomposing", "Decomposing Leaves")
|
def.tiles = {modname .. "_" .. def.texture .. ".png"}
|
||||||
|
|
||||||
|
def.drawtype = "glasslike"
|
||||||
|
def.paramtype = "light"
|
||||||
|
def.sunlight_propagates = true
|
||||||
|
|
||||||
|
def.groups = blockgame.underride(def.groups, {
|
||||||
|
planty = 1,
|
||||||
|
supports_leaves = 1,
|
||||||
|
air_flowable = 1,
|
||||||
|
can_fall = 1,
|
||||||
|
})
|
||||||
|
|
||||||
|
blockgame.register_node(modname .. ":" .. name, def)
|
||||||
|
end
|
||||||
|
|
||||||
|
reg_leaves("leaves", {
|
||||||
|
description = "Leaves",
|
||||||
|
})
|
||||||
|
reg_leaves("leaves_growing", {
|
||||||
|
description = "Growing Leaves",
|
||||||
|
drop = modname .. ":leaves",
|
||||||
|
texture = "leaves_alive",
|
||||||
|
fall_check = leaves_fall_check,
|
||||||
|
})
|
||||||
|
reg_leaves("leaves_alive", {
|
||||||
|
description = "Leaves",
|
||||||
|
drop = modname .. ":leaves",
|
||||||
|
fall_check = leaves_fall_check,
|
||||||
|
})
|
||||||
|
reg_leaves("leaves_decomposing", {
|
||||||
|
description = "Decomposing Leaves",
|
||||||
|
groups = {
|
||||||
|
supports_leaves = 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
blockgame.reg_simple_node("nut", "Nut", {
|
blockgame.reg_simple_node("nut", "Nut", {
|
||||||
woody = 1,
|
woody = 1,
|
||||||
|
|
Loading…
Reference in a new issue