flowers: Light check optimisation in mushroom spread
authorHybridDog <ovvv@web.de>
Sun, 31 Mar 2019 21:20:28 +0000 (23:20 +0200)
committerParamat <paramat@users.noreply.github.com>
Sun, 31 Mar 2019 21:20:28 +0000 (22:20 +0100)
mods/flowers/init.lua

index 5219a45575bab458f927405472e46a31061cc5b6..49799cf3537d2f3f1c92f6ca76a42b9a0d57f067 100644 (file)
@@ -221,8 +221,10 @@ minetest.register_node("flowers:mushroom_brown", {
 -- Mushroom spread and death
 
 function flowers.mushroom_spread(pos, node)
-       if minetest.get_node_light(pos, nil) == 15 then
-               minetest.remove_node(pos)
+       if minetest.get_node_light(pos, 0.5) > 3 then
+               if minetest.get_node_light(pos, nil) == 15 then
+                       minetest.remove_node(pos)
+               end
                return
        end
        local positions = minetest.find_nodes_in_area_under_air(
@@ -234,8 +236,7 @@ function flowers.mushroom_spread(pos, node)
        end
        local pos2 = positions[math.random(#positions)]
        pos2.y = pos2.y + 1
-       if minetest.get_node_light(pos, 0.5) <= 3 and
-                       minetest.get_node_light(pos2, 0.5) <= 3 then
+       if minetest.get_node_light(pos2, 0.5) <= 3 then
                minetest.set_node(pos2, {name = node.name})
        end
 end