Account for loaded but inactive sponge squeezers
Specifically for the case of sponge squeezers, not only do we need enough map around the artificial water to be loaded, we need it to actually be active, to be certain that the squeezer has an opportunity to run and keep the water fresh. This change should prevent specific water nodes from disappearing from sponge squeezers when they're right on the edge of the active mapblock range. This genericizes the API for checking the state of a mapblock, and adds a function to check if a mapblock is active, not merely loaded.
This commit is contained in:
parent
89c28203ad
commit
b49a7386d8
@ -28,9 +28,11 @@ function nodecore.within_map_limits(pos)
|
||||
and pos.z <= max
|
||||
end
|
||||
|
||||
function nodecore.near_unloaded(pos, node, dist)
|
||||
local function near_mapblock_state(pos, dist, func)
|
||||
pos = vector.floor(pos)
|
||||
if not (node or minetest.get_node_or_nil(pos)) then return true end
|
||||
|
||||
-- Optimistic check for the center first
|
||||
if func(pos) then return true end
|
||||
|
||||
if (not dist) or (dist < 1) then return end
|
||||
dist = math_floor(dist)
|
||||
@ -62,7 +64,7 @@ function nodecore.near_unloaded(pos, node, dist)
|
||||
pos.y = y
|
||||
for x = xmin, xmax, step do
|
||||
pos.x = x
|
||||
if not minetest.get_node_or_nil(pos) then return true end
|
||||
if func(pos) then return true end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -77,8 +79,22 @@ function nodecore.near_unloaded(pos, node, dist)
|
||||
pos.y = y
|
||||
for x = xmin, xmax, 16 do
|
||||
pos.x = x
|
||||
if not minetest.get_node_or_nil(pos) then return true end
|
||||
if func(pos) then return true end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
nodecore.near_mapblock_state = near_mapblock_state
|
||||
|
||||
function nodecore.near_unloaded(pos, node, dist)
|
||||
if node and node.name and node.name ~= "ignore" then return end
|
||||
return near_mapblock_state(pos, dist, function(p)
|
||||
return not minetest.get_node_or_nil(p)
|
||||
end)
|
||||
end
|
||||
|
||||
function nodecore.near_inactive(pos, _, dist)
|
||||
return near_mapblock_state(pos, dist, function(p)
|
||||
return not minetest.compare_block_status(p, "active")
|
||||
end)
|
||||
end
|
||||
|
@ -51,7 +51,7 @@ function nodecore.artificial_water_check(pos)
|
||||
return nodecore.dnt_set(pos, graywatersrc, data.recheck - nodecore.gametime)
|
||||
end
|
||||
|
||||
if nodecore.near_unloaded(pos, nil, 3) then
|
||||
if nodecore.near_inactive(pos, nil, 3) then
|
||||
return nodecore.dnt_set(pos, graywatersrc, 1 + math_random())
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user