forked from MineClone5/MineClone5
Use Perlin noise to initialize chorus growth
This commit is contained in:
parent
a6e4de2b6b
commit
4f0dbec948
|
@ -22,6 +22,10 @@ local OCEAN_MIN = -15
|
||||||
local DEEP_OCEAN_MAX = OCEAN_MIN - 1
|
local DEEP_OCEAN_MAX = OCEAN_MIN - 1
|
||||||
local DEEP_OCEAN_MIN = -31
|
local DEEP_OCEAN_MIN = -31
|
||||||
|
|
||||||
|
local minetest_get_perlin = minetest.get_perlin
|
||||||
|
local math_floor = math.floor
|
||||||
|
local math_abs = math.abs
|
||||||
|
|
||||||
--[[ Special biome field: _mcl_biome_type:
|
--[[ Special biome field: _mcl_biome_type:
|
||||||
Rough categorization of biomes: One of "snowy", "cold", "medium" and "hot"
|
Rough categorization of biomes: One of "snowy", "cold", "medium" and "hot"
|
||||||
Based off <https://minecraft.gamepedia.com/Biomes> ]]
|
Based off <https://minecraft.gamepedia.com/Biomes> ]]
|
||||||
|
@ -3922,6 +3926,16 @@ local function register_decorations()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Decorations in non-Overworld dimensions
|
-- Decorations in non-Overworld dimensions
|
||||||
|
|
||||||
|
local chorus_noise_params = {
|
||||||
|
offset = -0.012,
|
||||||
|
scale = 0.024,
|
||||||
|
spread = {x = 100, y = 100, z = 100},
|
||||||
|
seed = 257,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.6,
|
||||||
|
}
|
||||||
|
|
||||||
local function register_dimension_decorations()
|
local function register_dimension_decorations()
|
||||||
--[[ NETHER ]]
|
--[[ NETHER ]]
|
||||||
-- TODO: Nether
|
-- TODO: Nether
|
||||||
|
@ -3935,14 +3949,7 @@ local function register_dimension_decorations()
|
||||||
place_on = {"mcl_end:end_stone", "air"},
|
place_on = {"mcl_end:end_stone", "air"},
|
||||||
flags = "all_floors",
|
flags = "all_floors",
|
||||||
sidelen = 16,
|
sidelen = 16,
|
||||||
noise_params = {
|
noise_params = chorus_noise_params,
|
||||||
offset = -0.012,
|
|
||||||
scale = 0.024,
|
|
||||||
spread = {x = 100, y = 100, z = 100},
|
|
||||||
seed = 257,
|
|
||||||
octaves = 3,
|
|
||||||
persist = 0.6
|
|
||||||
},
|
|
||||||
y_min = mcl_mapgen.end_.min,
|
y_min = mcl_mapgen.end_.min,
|
||||||
y_max = mcl_mapgen.end_.max,
|
y_max = mcl_mapgen.end_.max,
|
||||||
decoration = "mcl_end:chorus_flower",
|
decoration = "mcl_end:chorus_flower",
|
||||||
|
@ -3962,6 +3969,8 @@ end
|
||||||
-- Detect mapgen to select functions
|
-- Detect mapgen to select functions
|
||||||
--
|
--
|
||||||
|
|
||||||
|
local chorus_perlin_noise
|
||||||
|
|
||||||
if not mcl_mapgen.singlenode then
|
if not mcl_mapgen.singlenode then
|
||||||
if not superflat then
|
if not superflat then
|
||||||
if not mcl_mapgen.v6 then
|
if not mcl_mapgen.v6 then
|
||||||
|
@ -3994,8 +4003,10 @@ if not mcl_mapgen.singlenode then
|
||||||
vm_context.gennotify = vm_context.gennotify or minetest.get_mapgen_object("gennotify")
|
vm_context.gennotify = vm_context.gennotify or minetest.get_mapgen_object("gennotify")
|
||||||
local gennotify = vm_context.gennotify
|
local gennotify = vm_context.gennotify
|
||||||
for _, pos in pairs(gennotify["decoration#"..deco_id_chorus_plant] or {}) do
|
for _, pos in pairs(gennotify["decoration#"..deco_id_chorus_plant] or {}) do
|
||||||
|
chorus_perlin_noise = chorus_perlin_noise or minetest_get_perlin(chorus_noise_params)
|
||||||
local realpos = { x = pos.x, y = pos.y + 1, z = pos.z }
|
local realpos = { x = pos.x, y = pos.y + 1, z = pos.z }
|
||||||
local pr = PseudoRandom(vm_context.blockseed)
|
local noise = chorus_perlin_noise:get_3d(realpos)
|
||||||
|
local pr = PseudoRandom(math_floor(math_abs(noise * 32767)) % 32768)
|
||||||
minetest.after(1, mcl_end.grow_chorus_plant, realpos, false, pr)
|
minetest.after(1, mcl_end.grow_chorus_plant, realpos, false, pr)
|
||||||
end
|
end
|
||||||
return vm_context
|
return vm_context
|
||||||
|
@ -4003,4 +4014,3 @@ if not mcl_mapgen.singlenode then
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue