forked from VoxeLibre/VoxeLibre
Spread grass and mycelium on a 3×5×3 area only
This commit is contained in:
parent
5fb6784813
commit
6221b060fc
|
@ -397,22 +397,25 @@ minetest.register_abm({
|
||||||
can_change = true
|
can_change = true
|
||||||
end
|
end
|
||||||
if can_change then
|
if can_change then
|
||||||
local light = minetest.get_node_light(above)
|
local light_self = minetest.get_node_light(above)
|
||||||
|
if not light_self then return end
|
||||||
|
--[[ Try to find a spreading dirt-type block (e.g. grass block or mycelium)
|
||||||
|
within a 3×5×3 area, with the source block being on the 2nd-topmost layer.
|
||||||
|
First we look around the source block, if we find nothing, we look below. ]]
|
||||||
local p2 = minetest.find_node_near(pos, 1, "group:spreading_dirt_type")
|
local p2 = minetest.find_node_near(pos, 1, "group:spreading_dirt_type")
|
||||||
if not p2 then
|
if not p2 then
|
||||||
return
|
p2 = minetest.find_node_near({x=pos.x,y=pos.y+2,z=pos.z}, 1, "group:spreading_dirt_type")
|
||||||
end
|
-- Nothing found on 2nd attempt? Bail out!
|
||||||
local n2 = minetest.get_node(p2)
|
if not p2 then return end
|
||||||
|
|
||||||
-- Light level for grass block and others
|
|
||||||
local minlight = 4
|
|
||||||
if n2.name == "mcl_core:mycelium" then
|
|
||||||
-- Light level for mycelium
|
|
||||||
minlight = 9
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if light >= minlight then
|
-- Found it! Now check light levels!
|
||||||
-- Spread the grass/mycelium!
|
local light_target = minetest.get_node_light({x=p2.x, y=p2.y+1, z=p2.z})
|
||||||
|
if not light_target then return end
|
||||||
|
|
||||||
|
if light_self >= 9 and light_target >= 4 then
|
||||||
|
-- All checks passed! Let's spread the grass/mycelium!
|
||||||
|
local n2 = minetest.get_node(p2)
|
||||||
minetest.set_node(pos, {name=n2.name})
|
minetest.set_node(pos, {name=n2.name})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue