forked from minetest/minetest_game
flowers: Light check optimisation in mushroom spread
This commit is contained in:
parent
88d79881b8
commit
b20725026e
@ -221,8 +221,10 @@ minetest.register_node("flowers:mushroom_brown", {
|
|||||||
-- Mushroom spread and death
|
-- Mushroom spread and death
|
||||||
|
|
||||||
function flowers.mushroom_spread(pos, node)
|
function flowers.mushroom_spread(pos, node)
|
||||||
if minetest.get_node_light(pos, nil) == 15 then
|
if minetest.get_node_light(pos, 0.5) > 3 then
|
||||||
minetest.remove_node(pos)
|
if minetest.get_node_light(pos, nil) == 15 then
|
||||||
|
minetest.remove_node(pos)
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local positions = minetest.find_nodes_in_area_under_air(
|
local positions = minetest.find_nodes_in_area_under_air(
|
||||||
@ -234,8 +236,7 @@ function flowers.mushroom_spread(pos, node)
|
|||||||
end
|
end
|
||||||
local pos2 = positions[math.random(#positions)]
|
local pos2 = positions[math.random(#positions)]
|
||||||
pos2.y = pos2.y + 1
|
pos2.y = pos2.y + 1
|
||||||
if minetest.get_node_light(pos, 0.5) <= 3 and
|
if minetest.get_node_light(pos2, 0.5) <= 3 then
|
||||||
minetest.get_node_light(pos2, 0.5) <= 3 then
|
|
||||||
minetest.set_node(pos2, {name = node.name})
|
minetest.set_node(pos2, {name = node.name})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user