From 888251e3ec79de8997e91af3b1e88f760c69ee92 Mon Sep 17 00:00:00 2001 From: kay27 Date: Fri, 18 Mar 2022 01:03:40 +0400 Subject: [PATCH] #1976 Use Perlin noise to initialize chorus growth --- mods/CORE/mcl_mapgen/init.lua | 2 +- mods/MAPGEN/mcl_biomes/init.lua | 29 ++++++++++++++++++++--------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/mods/CORE/mcl_mapgen/init.lua b/mods/CORE/mcl_mapgen/init.lua index 6f4442d81..4ca7e0055 100644 --- a/mods/CORE/mcl_mapgen/init.lua +++ b/mods/CORE/mcl_mapgen/init.lua @@ -364,7 +364,7 @@ minetest.register_on_generated(function(minp, maxp, chunkseed) -- mcl_mapgen.register_mapgen_lvm(function(vm_context), order_number) -- -- -- for _, v in pairs(queue_chunks_lvm) do - vm_context = v.f(vm_context) + v.f(vm_context) end -- -- -- mcl_mapgen.register_mapgen(function(minp, maxp, chunkseed, vm_context), order_number) -- diff --git a/mods/MAPGEN/mcl_biomes/init.lua b/mods/MAPGEN/mcl_biomes/init.lua index 9ab93d234..ef1bca585 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -22,6 +22,10 @@ local OCEAN_MIN = -15 local DEEP_OCEAN_MAX = OCEAN_MIN - 1 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: Rough categorization of biomes: One of "snowy", "cold", "medium" and "hot" Based off ]] @@ -3908,6 +3912,16 @@ local function register_decorations() end -- 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() --[[ NETHER ]] -- TODO: Nether @@ -3921,14 +3935,7 @@ local function register_dimension_decorations() place_on = {"mcl_end:end_stone", "air"}, flags = "all_floors", sidelen = 16, - noise_params = { - offset = -0.012, - scale = 0.024, - spread = {x = 100, y = 100, z = 100}, - seed = 257, - octaves = 3, - persist = 0.6 - }, + noise_params = chorus_noise_params, y_min = mcl_mapgen.end_.min, y_max = mcl_mapgen.end_.max, decoration = "mcl_end:chorus_flower", @@ -3948,6 +3955,8 @@ end -- Detect mapgen to select functions -- +local chorus_perlin_noise + if not mcl_mapgen.singlenode then if not superflat then if not mcl_mapgen.v6 then @@ -3980,8 +3989,10 @@ if not mcl_mapgen.singlenode then vm_context.gennotify = vm_context.gennotify or minetest.get_mapgen_object("gennotify") local gennotify = vm_context.gennotify 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 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) end return vm_context