mirror of
https://github.com/mt-mods/biome_lib.git
synced 2025-07-22 18:00:31 +02:00
Compare commits
1 Commits
extra-map-
...
43b2c6db42
Author | SHA1 | Date | |
---|---|---|---|
43b2c6db42 |
39
init.lua
39
init.lua
@ -34,7 +34,7 @@ local function tableize(s)
|
||||
return string.split(string.trim(string.gsub(s, " ", "")))
|
||||
end
|
||||
|
||||
local c1 = minetest.settings:get("biome_lib_default_grow_through_nodes")
|
||||
local c1 minetest.settings:get("biome_lib_default_grow_through_nodes")
|
||||
biome_lib.default_grow_through_nodes = {["air"] = true}
|
||||
if c1 then
|
||||
for _, i in ipairs(tableize(c1)) do
|
||||
@ -44,7 +44,7 @@ else
|
||||
biome_lib.default_grow_through_nodes["default:snow"] = true
|
||||
end
|
||||
|
||||
local c2 = minetest.settings:get("biome_lib_default_water_nodes")
|
||||
local c2 minetest.settings:get("biome_lib_default_water_nodes")
|
||||
biome_lib.default_water_nodes = {}
|
||||
if c2 then
|
||||
for _, i in ipairs(tableize(c2)) do
|
||||
@ -427,22 +427,10 @@ function biome_lib:populate_surfaces(biome, nodes_or_function_or_model, snodes,
|
||||
return items_added
|
||||
end
|
||||
|
||||
-- make sure the target block and all 6 neighbors are actually loaded.
|
||||
|
||||
local function confirm_block_surroundings(pos)
|
||||
return minetest.get_node_or_nil(pos)
|
||||
and minetest.get_node_or_nil({ x=pos.x-16, y=pos.y, z=pos.z })
|
||||
and minetest.get_node_or_nil({ x=pos.x+16, y=pos.y, z=pos.z })
|
||||
and minetest.get_node_or_nil({ x=pos.x, y=pos.y-16, z=pos.z })
|
||||
and minetest.get_node_or_nil({ x=pos.x, y=pos.y+16, z=pos.z })
|
||||
and minetest.get_node_or_nil({ x=pos.x, y=pos.y, z=pos.z-16 })
|
||||
and minetest.get_node_or_nil({ x=pos.x, y=pos.y, z=pos.z+16 })
|
||||
end
|
||||
|
||||
-- Primary mapgen spawner, for mods that can work with air checking enabled on
|
||||
-- a surface during the initial map read stage.
|
||||
|
||||
function biome_lib:generate_block_with_air_checking(shutdown)
|
||||
function biome_lib:generate_block_with_air_checking()
|
||||
if not biome_lib.blocklist_aircheck[1] then
|
||||
return
|
||||
end
|
||||
@ -462,10 +450,8 @@ function biome_lib:generate_block_with_air_checking(shutdown)
|
||||
if #biome_lib.surface_nodes_aircheck.blockhash > 0 then
|
||||
biome_lib:dbg("Mapblock at "..minetest.pos_to_string(minp).." added, with "..#biome_lib.surface_nodes_aircheck.blockhash.." surface nodes detected.")
|
||||
end
|
||||
elseif not shutdown and not confirm_block_surroundings(minp) and #biome_lib.blocklist_aircheck > 1 then
|
||||
biome_lib.blocklist_aircheck[#biome_lib.blocklist_aircheck+1] = biome_lib.blocklist_aircheck[1]
|
||||
table.remove(biome_lib.blocklist_aircheck, 1)
|
||||
biome_lib:dbg("Mapblock at "..minetest.pos_to_string(minp).." had an unloaded neighbor, moved it to the end of the queue.")
|
||||
elseif not minetest.get_node_or_nil(minp) then
|
||||
minetest.load_area(minp)
|
||||
else
|
||||
if biome_lib.actionslist_aircheck[biome_lib.actioncount_aircheck.blockhash] then
|
||||
-- [1] is biome, [2] is node/function/model
|
||||
@ -489,7 +475,7 @@ end
|
||||
-- Secondary mapgen spawner, for mods that require disabling of
|
||||
-- checking for air during the initial map read stage.
|
||||
|
||||
function biome_lib:generate_block_no_aircheck(shutdown)
|
||||
function biome_lib:generate_block_no_aircheck()
|
||||
if not biome_lib.blocklist_no_aircheck[1] then
|
||||
return
|
||||
end
|
||||
@ -503,9 +489,8 @@ function biome_lib:generate_block_no_aircheck(shutdown)
|
||||
biome_lib.surface_nodes_no_aircheck.blockhash =
|
||||
minetest.find_nodes_in_area(minp, maxp, biome_lib.surfaceslist_no_aircheck)
|
||||
biome_lib.actioncount_no_aircheck.blockhash = 1
|
||||
elseif not shutdown and not confirm_block_surroundings(minp) and #biome_lib.blocklist_no_aircheck > 1 then
|
||||
biome_lib.blocklist_no_aircheck[#biome_lib.blocklist_no_aircheck+1] = biome_lib.blocklist_no_aircheck[1]
|
||||
table.remove(biome_lib.blocklist_no_aircheck, 1)
|
||||
elseif not minetest.get_node_or_nil(minp) then
|
||||
minetest.load_area(minp)
|
||||
else
|
||||
if biome_lib.actionslist_no_aircheck[biome_lib.actioncount_no_aircheck.blockhash] then
|
||||
biome_lib:populate_surfaces(
|
||||
@ -536,10 +521,10 @@ minetest.register_globalstep(function(dtime)
|
||||
while (#biome_lib.blocklist_aircheck > 0 or #biome_lib.blocklist_no_aircheck > 0)
|
||||
and biome_lib.globalstep_runtime < 200000 do -- 0.2 seconds, in uS.
|
||||
if #biome_lib.blocklist_aircheck > 0 then
|
||||
biome_lib:generate_block_with_air_checking(false)
|
||||
biome_lib:generate_block_with_air_checking()
|
||||
end
|
||||
if #biome_lib.blocklist_no_aircheck > 0 then
|
||||
biome_lib:generate_block_no_aircheck(false)
|
||||
biome_lib:generate_block_no_aircheck()
|
||||
end
|
||||
biome_lib.globalstep_runtime = minetest.get_us_time() - biome_lib.globalstep_start_time
|
||||
end
|
||||
@ -556,7 +541,7 @@ minetest.register_on_shutdown(function()
|
||||
print("[biome_lib] Stand by, playing out the rest of the aircheck mapblock log")
|
||||
print("(there are "..#biome_lib.blocklist_aircheck.." entries)...")
|
||||
while #biome_lib.blocklist_aircheck > 0 do
|
||||
biome_lib:generate_block_with_air_checking(true)
|
||||
biome_lib:generate_block_with_air_checking(0.1)
|
||||
end
|
||||
end)
|
||||
|
||||
@ -568,7 +553,7 @@ minetest.register_on_shutdown(function()
|
||||
print("[biome_lib] Stand by, playing out the rest of the no-aircheck mapblock log")
|
||||
print("(there are "..#biome_lib.blocklist_no_aircheck.." entries)...")
|
||||
while #biome_lib.blocklist_no_aircheck > 0 do
|
||||
biome_lib:generate_block_no_aircheck(true)
|
||||
biome_lib:generate_block_no_aircheck(0.1)
|
||||
end
|
||||
end)
|
||||
|
||||
|
Reference in New Issue
Block a user