Remove leafdecay

master
PilzAdam 2012-10-19 18:49:34 +02:00
parent ceac78ae23
commit a573ec2345
2 changed files with 2 additions and 71 deletions

View File

@ -1,7 +1,6 @@
default = {}
dofile(minetest.get_modpath("default").."/mapgen.lua")
dofile(minetest.get_modpath("default").."/leafdecay.lua")
minetest.register_item(":", {
type = "none",
@ -442,7 +441,7 @@ minetest.register_node("default:gravel", {
minetest.register_node("default:tree", {
description = "Tree",
tiles = {"default_tree_top.png", "default_tree_top.png", "default_tree.png"},
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
sounds = default.node_sound_wood_defaults(),
})
@ -454,7 +453,7 @@ minetest.register_node("default:leaves", {
paramtype = "light",
walkable = false,
climbable = true,
groups = {snappy=3, leafdecay=3, flammable=2},
groups = {snappy=3,flammable=2},
drop = {
max_items = 1,
items = {

View File

@ -1,68 +0,0 @@
default.leafdecay_trunk_cache = {}
default.leafdecay_enable_cache = true
default.leafdecay_trunk_find_allow_accumulator = 0
minetest.register_globalstep(function(dtime)
local finds_per_second = 5000
default.leafdecay_trunk_find_allow_accumulator =
math.floor(dtime * finds_per_second)
end)
minetest.register_abm({
nodenames = {"group:leafdecay"},
neighbors = {"air", "group:liquid"},
interval = 2,
chance = 5,
action = function(p0, node, _, _)
local do_preserve = false
local d = minetest.registered_nodes[node.name].groups.leafdecay
if not d or d == 0 then
return
end
local n0 = minetest.env:get_node(p0)
if n0.param2 ~= 0 then
return
end
local p0_hash = nil
if default.leafdecay_enable_cache then
p0_hash = minetest.hash_node_position(p0)
local trunkp = default.leafdecay_trunk_cache[p0_hash]
if trunkp then
local n = minetest.env:get_node(trunkp)
local reg = minetest.registered_nodes[n.name]
if n.name == "ignore" or (reg.groups.tree and reg.groups.tree ~= 0) then
return
end
table.remove(default.leafdecay_trunk_cache, p0_hash)
end
end
if default.leafdecay_trunk_find_allow_accumulator <= 0 then
return
end
default.leafdecay_trunk_find_allow_accumulator =
default.leafdecay_trunk_find_allow_accumulator - 1
local p1 = minetest.env:find_node_near(p0, d, {"ignore", "group:tree"})
if p1 then
do_preserve = true
if default.leafdecay_enable_cache then
default.leafdecay_trunk_cache[p0_hash] = p1
end
end
if not do_preserve then
itemstacks = minetest.get_node_drops(n0.name)
for _, itemname in ipairs(itemstacks) do
if itemname ~= n0.name then
local p_drop = {
x = p0.x - 0.5 + math.random(),
y = p0.y - 0.5 + math.random(),
z = p0.z - 0.5 + math.random(),
}
minetest.env:add_item(p_drop, itemname)
end
end
minetest.env:remove_node(p0)
end
end
})