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