forked from VoxeLibre/VoxeLibre
Prevent leafdecay for player-placed leaves
This commit is contained in:
parent
e941ce5708
commit
cac94551df
|
@ -518,16 +518,15 @@ minetest.register_abm({
|
|||
chance = 5,
|
||||
|
||||
action = function(p0, node, _, _)
|
||||
--print("leafdecay ABM at "..p0.x..", "..p0.y..", "..p0.z..")")
|
||||
local do_preserve = false
|
||||
local d = minetest.registered_nodes[node.name].groups.leafdecay
|
||||
if not d or d == 0 then
|
||||
--print("not groups.leafdecay")
|
||||
return
|
||||
end
|
||||
local n0 = minetest.get_node(p0)
|
||||
if n0.param2 ~= 0 then
|
||||
--print("param2 ~= 0")
|
||||
-- Prevent leafdecay for player-placed leaves.
|
||||
-- param2 is set to 1 after it was placed by the player
|
||||
return
|
||||
end
|
||||
local p0_hash = nil
|
||||
|
@ -539,10 +538,8 @@ minetest.register_abm({
|
|||
local reg = minetest.registered_nodes[n.name]
|
||||
-- Assume ignore is a trunk, to make the thing work at the border of the active area
|
||||
if n.name == "ignore" or (reg and reg.groups.tree and reg.groups.tree ~= 0) then
|
||||
--print("cached trunk still exists")
|
||||
return
|
||||
end
|
||||
--print("cached trunk is invalid")
|
||||
-- Cache is invalid
|
||||
table.remove(mcl_core.leafdecay_trunk_cache, p0_hash)
|
||||
end
|
||||
|
@ -557,7 +554,6 @@ minetest.register_abm({
|
|||
if p1 then
|
||||
do_preserve = true
|
||||
if mcl_core.leafdecay_enable_cache then
|
||||
--print("caching trunk")
|
||||
-- Cache the trunk
|
||||
mcl_core.leafdecay_trunk_cache[p0_hash] = p1
|
||||
end
|
||||
|
|
|
@ -612,6 +612,7 @@ minetest.register_node("mcl_core:sapling", {
|
|||
minetest.register_node("mcl_core:leaves", {
|
||||
description = "Oak Leaves",
|
||||
drawtype = "allfaces_optional",
|
||||
place_param2 = 1, -- Prevent leafdecay for placed nodes
|
||||
visual_scale = 1.3,
|
||||
tiles = {"default_leaves.png"},
|
||||
paramtype = "light",
|
||||
|
@ -688,6 +689,7 @@ minetest.register_node("mcl_core:darksapling", {
|
|||
minetest.register_node("mcl_core:darkleaves", {
|
||||
description = "Dark Oak Leaves",
|
||||
drawtype = "allfaces_optional",
|
||||
place_param2 = 1, -- Prevent leafdecay for placed nodes
|
||||
visual_scale = 1.3,
|
||||
tiles = {"default_leaves_big_oak.png"},
|
||||
paramtype = "light",
|
||||
|
@ -774,6 +776,7 @@ minetest.register_node("mcl_core:junglewood", {
|
|||
minetest.register_node("mcl_core:jungleleaves", {
|
||||
description = "Jungle Leaves",
|
||||
drawtype = "allfaces_optional",
|
||||
place_param2 = 1, -- Prevent leafdecay for placed nodes
|
||||
visual_scale = 1.3,
|
||||
tiles = {"default_jungleleaves.png"},
|
||||
paramtype = "light",
|
||||
|
@ -796,6 +799,7 @@ minetest.register_node("mcl_core:jungleleaves", {
|
|||
minetest.register_node("mcl_core:junglesapling", {
|
||||
description = "Jungle Sapling",
|
||||
drawtype = "plantlike",
|
||||
place_param2 = 1, -- Prevent leafdecay for placed nodes
|
||||
visual_scale = 1.0,
|
||||
tiles = {"default_junglesapling.png"},
|
||||
inventory_image = "default_junglesapling.png",
|
||||
|
@ -846,6 +850,7 @@ minetest.register_node("mcl_core:acaciawood", {
|
|||
minetest.register_node("mcl_core:acacialeaves", {
|
||||
description = "Acacia Leaves",
|
||||
drawtype = "allfaces_optional",
|
||||
place_param2 = 1, -- Prevent leafdecay for placed nodes
|
||||
visual_scale = 1.3,
|
||||
tiles = {"default_acacialeaves.png"},
|
||||
paramtype = "light",
|
||||
|
@ -917,6 +922,7 @@ minetest.register_node("mcl_core:sprucewood", {
|
|||
minetest.register_node("mcl_core:spruceleaves", {
|
||||
description = "Spruce Leaves",
|
||||
drawtype = "allfaces_optional",
|
||||
place_param2 = 1, -- Prevent leafdecay for placed nodes
|
||||
visual_scale = 1.3,
|
||||
tiles = {"default_spruceleaves.png"},
|
||||
paramtype = "light",
|
||||
|
@ -994,6 +1000,7 @@ minetest.register_node("mcl_core:birchwood", {
|
|||
minetest.register_node("mcl_core:birchleaves", {
|
||||
description = "Birch Leaves",
|
||||
drawtype = "allfaces_optional",
|
||||
place_param2 = 1, -- Prevent leafdecay for placed nodes
|
||||
visual_scale = 1.3,
|
||||
tiles = {"default_leaves_birch.png"},
|
||||
paramtype = "light",
|
||||
|
|
Reference in New Issue