Rudimentary cleanup of falling leaf node issues.

When a leaf node is displaced by crushing by a falling node,
instead of ejecting an item, try to place the node itself within
a reasonable distance.

This shoudl reduce the number of stack nodes generated from tree
canopy decay, and should alleviate the inconsistency of leaves
falling sometimes as nodes and sometimes as stacks.
This commit is contained in:
Aaron Suen 2019-09-12 20:56:51 -04:00
parent 05c60e031a
commit 72e35ce9ab
2 changed files with 44 additions and 10 deletions

View File

@ -9,18 +9,13 @@ ISSUES: Bugs, Cleanup and Refinements
# # # # # # # # # # # #
#### # #### # ###### ###### # # ####
- Redesign how falling_nodes pile up.
- Make sure nodes are not destroyed.
- Allow node displacement sideways?
- Maybe force column to coordinate settling in order, to
avoid race conditions?
- Check for early settling on node of same type, e.g. for
falling leaves.
- First-class support for stack "pez dispensers".
- Upon digging a stack node, try to shift all inventories from
stack nodes above downward.
- Sponges grow way too much.
- Inhibit growth based on total neighbors.
- Hint system updates.
- Need a "witness" system for spontaneous in-world processes,
such as tree growth or lode cooling. Credit players within

View File

@ -1,10 +1,29 @@
-- LUALOCALS < ---------------------------------------------------------
local ItemStack, minetest, setmetatable
= ItemStack, minetest, setmetatable
local ItemStack, math, minetest, nodecore, pairs, setmetatable, unpack
= ItemStack, math, minetest, nodecore, pairs, setmetatable, unpack
local math_random
= math.random
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
local function readd(oldadd, pos, item, ...)
local stack = ItemStack(item)
item = stack:get_name()
if stack:get_count() ~= 1 or (not
minetest.registered_nodes[item]) then
return oldadd(pos, item, ...)
end
pos = nodecore.scan_flood(pos, 5,
function(p)
if p.y > pos.y and math_random() < 0.95 then return end
if p.y > pos.y + 1 then return end
if nodecore.buildable_to(p) then return p end
end)
if not pos then return oldadd(pos, item, ...) end
minetest.set_node(pos, {name = item})
end
local bifn = minetest.registered_entities["__builtin:falling_node"]
local falling = {
set_node = function(self, node, meta, ...)
@ -18,6 +37,26 @@ local falling = {
end
end
return bifn.set_node(self, node, meta, ...)
end,
on_step = function(...)
local oldadd = minetest.add_item
local drops = {}
minetest.add_item = function(pos, item, ...)
drops[#drops + 1] = {pos, item, ...}
end
local oldnode = minetest.add_node
minetest.add_node = function(pos, node, ...)
oldnode(pos, node, ...)
for _, v in pairs(drops) do
readd(oldadd, unpack(v))
end
drops = {}
end
local function helper(...)
minetest.add_item = oldadd
return ...
end
return helper(bifn.on_step(...))
end
}
setmetatable(falling, bifn)