1
0
Fork 0

Merge pull request 'Mapgen optimisations' (#3607) from mapgen_optimisation into master

Reviewed-on: MineClone2/MineClone2#3607
This commit is contained in:
ancientmarinerdev 2023-04-01 19:03:09 +00:00
commit bfea20dd00
2 changed files with 84 additions and 45 deletions

View File

@ -6066,10 +6066,8 @@ if mg_name ~= "singlenode" then
for _, f in pairs(deco_ids_trees) do for _, f in pairs(deco_ids_trees) do
minetest.set_gen_notify({decoration = true}, {f}) minetest.set_gen_notify({decoration = true}, {f})
end end
if deco_id_chorus_plant or deco_ids_fungus or deco_ids_trees then
mcl_mapgen_core.register_generator("chorus_grow", nil, function(minp, maxp, blockseed) local function mangrove_roots_gen(gennotify, pr)
local gennotify = minetest.get_mapgen_object("gennotify")
local pr = PseudoRandom(blockseed + 14)
for _, f in pairs(deco_ids_trees) do for _, f in pairs(deco_ids_trees) do
for _, pos in ipairs(gennotify["decoration#" .. f] or {}) do for _, pos in ipairs(gennotify["decoration#" .. f] or {}) do
local nn = minetest.find_nodes_in_area(vector.offset(pos, -8, -1, -8), vector.offset(pos, 8, 0, 8), {"mcl_mangrove:mangrove_roots"}) local nn = minetest.find_nodes_in_area(vector.offset(pos, -8, -1, -8), vector.offset(pos, 8, 0, 8), {"mcl_mangrove:mangrove_roots"})
@ -6090,9 +6088,9 @@ if mg_name ~= "singlenode" then
end end
end end
end end
if minp.y > -26900 then
return
end end
local function chorus_gen (gennotify, pr)
for _, pos in ipairs(gennotify["decoration#" .. deco_id_chorus_plant] or {}) do for _, pos in ipairs(gennotify["decoration#" .. deco_id_chorus_plant] or {}) do
local x, y, z = pos.x, pos.y, pos.z local x, y, z = pos.x, pos.y, pos.z
if x < -10 or x > 10 or z < -10 or z > 10 then if x < -10 or x > 10 or z < -10 or z > 10 then
@ -6103,14 +6101,48 @@ if mg_name ~= "singlenode" then
end end
end end
end end
if minp.y > mcl_vars.mg_nether_max then
return
end end
local function crimson_warped_gen(gennotify)
for _, f in pairs(deco_ids_fungus) do for _, f in pairs(deco_ids_fungus) do
for _, pos in ipairs(gennotify["decoration#" .. f] or {}) do for _, pos in ipairs(gennotify["decoration#" .. f] or {}) do
minetest.fix_light(vector.offset(pos, -8, -8, -8), vector.offset(pos, 8, 8, 8)) minetest.fix_light(vector.offset(pos, -8, -8, -8), vector.offset(pos, 8, 8, 8))
end end
end end
end
if deco_id_chorus_plant or deco_ids_fungus or deco_ids_trees then
mcl_mapgen_core.register_generator("chorus_grow", nil, function(minp, maxp, blockseed)
local gennotify = minetest.get_mapgen_object("gennotify")
local pr = PseudoRandom(blockseed + 14)
if not (maxp.y < mcl_vars.mg_overworld_min or minp.y > mcl_vars.mg_overworld_max) then
local biomemap = minetest.get_mapgen_object("biomemap")
--minetest.log("mangrove stuff: " .. dump(biomemap))
local swamp_biome_id = minetest.get_biome_id("MangroveSwamp")
local swamp_shore_id = minetest.get_biome_id("MangroveSwamp_shore")
local is_swamp = table.indexof(biomemap, swamp_biome_id) ~= -1
local is_swamp_shore = table.indexof(biomemap, swamp_shore_id) ~= -1
if is_swamp or is_swamp_shore then
--minetest.log("Mangrove swamp biomes...")
--minetest.log("is_swamp: " .. dump(is_swamp))
--minetest.log("is_swamp_shore: " .. dump(is_swamp_shore))
mangrove_roots_gen(gennotify, pr)
else
--minetest.log("is not mangrove swamp biomes...")
end
end
if not (maxp.y < mcl_vars.mg_end_min or minp.y > mcl_vars.mg_end_max) then
--minetest.log("chorus stuff")
chorus_gen(gennotify, pr)
end
if not (maxp.y < mcl_vars.mg_nether_min or minp.y > mcl_vars.mg_nether_max) then
--minetest.log("nether stuff")
crimson_warped_gen(gennotify)
end
end) end)
end end

View File

@ -346,9 +346,16 @@ local function world_structure(vm, data, data2, emin, emax, area, minp, maxp, bl
end end
local function block_fixes_grass(vm, data, data2, emin, emax, area, minp, maxp, blockseed) local function block_fixes_grass(vm, data, data2, emin, emax, area, minp, maxp, blockseed)
if maxp.y < mcl_vars.mg_overworld_min then
--minetest.log("Exit grass fix")
return
else
--minetest.log("Grass fixes")
end
local biomemap = minetest.get_mapgen_object("biomemap") local biomemap = minetest.get_mapgen_object("biomemap")
local lvm_used = false local lvm_used = false
local pr = PseudoRandom(blockseed)
if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then
-- Set param2 (=color) of nodes which use the grass colour palette. -- Set param2 (=color) of nodes which use the grass colour palette.
lvm_used = set_grass_palette(minp,maxp,data2,area,biomemap,{"group:grass_palette"}) lvm_used = set_grass_palette(minp,maxp,data2,area,biomemap,{"group:grass_palette"})