forked from MineClone5/MineClone5
Grass block: Change grass color depending on biome
This commit is contained in:
parent
2d34a2982a
commit
1b7c41fc81
|
@ -639,6 +639,23 @@ end
|
|||
|
||||
local grass_spread_randomizer = PseudoRandom(minetest.get_mapgen_setting("seed"))
|
||||
|
||||
-- Return appropriate grass block node for pos. Dry grass for dry/hot biomes, normal grass otherwise.
|
||||
function mcl_core.get_grass_block_type(pos)
|
||||
local biome_data = minetest.get_biome_data(pos)
|
||||
local dry = false
|
||||
if biome_data then
|
||||
local biome = biome_data.biome
|
||||
local biome_name = minetest.get_biome_name(biome)
|
||||
local biome_type = minetest.registered_biomes[biome_name]._mcl_biome_type
|
||||
dry = biome_type == "hot"
|
||||
end
|
||||
if dry then
|
||||
return {name="mcl_core:dirt_with_dry_grass"}
|
||||
else
|
||||
return {name="mcl_core:dirt_with_grass"}
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------
|
||||
-- Spread grass blocks and mycelium on neighbor dirt
|
||||
------------------------------
|
||||
|
@ -681,6 +698,9 @@ minetest.register_abm({
|
|||
if light_self >= 4 and light_source >= 9 then
|
||||
-- All checks passed! Let's spread the grass/mycelium!
|
||||
local n2 = minetest.get_node(p2)
|
||||
if minetest.get_item_group(n2.name, "grass_block") ~= 0 then
|
||||
n2 = mcl_core.get_grass_block_type(pos)
|
||||
end
|
||||
minetest.set_node(pos, {name=n2.name})
|
||||
|
||||
-- If this was mycelium, uproot plant above
|
||||
|
|
|
@ -321,18 +321,9 @@ minetest.register_node("mcl_core:dirt_with_grass", {
|
|||
footstep = {name="default_grass_footstep", gain=0.4},
|
||||
}),
|
||||
on_construct = function(pos)
|
||||
local dim = mcl_worlds.pos_to_dimension(pos)
|
||||
local dry
|
||||
if dim == "nether" then
|
||||
dry = true
|
||||
else
|
||||
local found_node = minetest.find_node_near(pos, 1, {"mcl_core:dirt_with_dry_grass", "mcl_core:dirt_with_dry_grass_snow"})
|
||||
if found_node then
|
||||
dry = true
|
||||
end
|
||||
end
|
||||
if dry then
|
||||
minetest.set_node(pos, {name="mcl_core:dirt_with_dry_grass"})
|
||||
local new_node = mcl_core.get_grass_block_type(pos)
|
||||
if new_node.name ~= "mcl_core:dirt_with_grass" then
|
||||
minetest.set_node(pos, new_node)
|
||||
end
|
||||
return mcl_core.on_snowable_construct(pos)
|
||||
end,
|
||||
|
|
Loading…
Reference in New Issue