Spread grass block and mycelium to lit dirt
This commit is contained in:
parent
d0c7527232
commit
5fb6784813
@ -34,6 +34,7 @@ Please read <http://minecraft.gamepedia.com/Breaking> to learn how digging times
|
||||
* `cultivatable=2`: Block will be turned into Farmland by using a hoe on it
|
||||
* `cultivatable=1`: Block will be turned into Dirt by using a hoe on it
|
||||
* `flammable`: Block helps spreading fire and gets destroyed by nearby fire (rating doesn't matter)
|
||||
* `spreading_dirt_type=1`: A dirt-type block with a cover (e.g. grass) which may spread to neighbor dirt blocks
|
||||
* `soil=1`: Saplings and other small plants can grow on it
|
||||
* `soil_sapling=2`: Soil for saplings. Intended to be natural soil. All saplings will grow on this
|
||||
* `soil_sapling=1`: Artificial soil (such as farmland) for saplings. Some saplings will not grow on this
|
||||
|
@ -379,35 +379,44 @@ function mcl_core.generate_tree(pos, trunk, leaves, typearbre)
|
||||
end
|
||||
|
||||
------------------------------
|
||||
-- Try generate grass dirt ---
|
||||
-- Spread grass blocks and mycelium on neighbor dirt
|
||||
------------------------------
|
||||
-- turn dirt to dirt with grass
|
||||
minetest.register_abm({
|
||||
nodenames = {"mcl_core:dirt"},
|
||||
neighbors = {"air"},
|
||||
neighbors = {"air", "mcl_core:dirt_with_grass", "mcl_core:mycelium"},
|
||||
interval = 30,
|
||||
chance = 20,
|
||||
action = function(pos)
|
||||
if pos == nil then
|
||||
return
|
||||
end
|
||||
local can_change = 0
|
||||
for i=1,4 do
|
||||
local p = {x=pos.x, y=pos.y+i, z=pos.z}
|
||||
local n = minetest.get_node(p)
|
||||
-- On verifie si il y a de l'air
|
||||
if (n.name=="air") then
|
||||
can_change = can_change + 1
|
||||
if pos == nil then
|
||||
return
|
||||
end
|
||||
local can_change = false
|
||||
local above = {x=pos.x, y=pos.y+1, z=pos.z}
|
||||
local abovenode = minetest.get_node(above)
|
||||
if (abovenode.name=="air") then
|
||||
can_change = true
|
||||
end
|
||||
if can_change then
|
||||
local light = minetest.get_node_light(above)
|
||||
local p2 = minetest.find_node_near(pos, 1, "group:spreading_dirt_type")
|
||||
if not p2 then
|
||||
return
|
||||
end
|
||||
end
|
||||
if can_change > 3 then
|
||||
local light = minetest.get_node_light(pos)
|
||||
if light or light > 10 then
|
||||
minetest.add_node(pos, {name="mcl_core:dirt_with_grass"})
|
||||
local n2 = minetest.get_node(p2)
|
||||
|
||||
-- Light level for grass block and others
|
||||
local minlight = 4
|
||||
if n2.name == "mcl_core:mycelium" then
|
||||
-- Light level for mycelium
|
||||
minlight = 9
|
||||
end
|
||||
|
||||
if light >= minlight then
|
||||
-- Spread the grass/mycelium!
|
||||
minetest.set_node(pos, {name=n2.name})
|
||||
end
|
||||
end
|
||||
end,
|
||||
end
|
||||
})
|
||||
|
||||
--------------------------
|
||||
|
@ -366,7 +366,7 @@ minetest.register_node("mcl_core:dirt_with_grass", {
|
||||
tiles = {"default_grass.png", "default_dirt.png", "default_grass_side.png"},
|
||||
is_ground_content = true,
|
||||
stack_max = 64,
|
||||
groups = {handy=1,shovely=1, soil=1, soil_sapling=2, soil_sugarcane=1, cultivatable=2, building_block=1},
|
||||
groups = {handy=1,shovely=1, soil=1, soil_sapling=2, soil_sugarcane=1, cultivatable=2, spreading_dirt_type=1, building_block=1},
|
||||
drop = 'mcl_core:dirt',
|
||||
sounds = mcl_sounds.node_sound_dirt_defaults({
|
||||
footstep = {name="default_grass_footstep", gain=0.4},
|
||||
@ -422,7 +422,7 @@ minetest.register_node("mcl_core:mycelium", {
|
||||
tiles = {"default_mycelium_top.png", "default_dirt.png", "default_mycelium_side.png"},
|
||||
is_ground_content = true,
|
||||
stack_max = 64,
|
||||
groups = {handy=1,shovely=1, building_block=1},
|
||||
groups = {handy=1,shovely=1, spreading_dirt_type=1, building_block=1},
|
||||
drop = 'mcl_core:dirt',
|
||||
sounds = mcl_sounds.node_sound_dirt_defaults({
|
||||
footstep = {name="default_grass_footstep", gain=0.4},
|
||||
|
Loading…
Reference in New Issue
Block a user