mirror of
https://github.com/mt-mods/biome_lib.git
synced 2025-07-21 09:20:31 +02:00
Compare commits
5 Commits
non_mtg
...
43b2c6db42
Author | SHA1 | Date | |
---|---|---|---|
43b2c6db42 | |||
9ed4858518 | |||
26dbbb5a67 | |||
ec0a0f0c3b | |||
e92361675f |
26
init.lua
26
init.lua
@ -9,8 +9,6 @@
|
||||
biome_lib = {}
|
||||
biome_lib.air = {name = "air"}
|
||||
|
||||
plantslib = setmetatable({}, { __index=function(t,k) print("Use of deprecated function:", k) return biome_lib[k] end })
|
||||
|
||||
biome_lib.blocklist_aircheck = {}
|
||||
biome_lib.blocklist_no_aircheck = {}
|
||||
|
||||
@ -160,7 +158,7 @@ function biome_lib:set_defaults(biome)
|
||||
biome.near_nodes_size = biome.near_nodes_size or 0
|
||||
biome.near_nodes_count = biome.near_nodes_count or 1
|
||||
biome.rarity = biome.rarity or 50
|
||||
biome.max_count = biome.max_count or 5
|
||||
biome.max_count = biome.max_count or 125
|
||||
if biome.check_air ~= false then biome.check_air = true end
|
||||
|
||||
-- specific to abm spawner
|
||||
@ -331,6 +329,7 @@ local function populate_single_surface(biome, pos, perlin_fertile_area, checkair
|
||||
end
|
||||
|
||||
function biome_lib:populate_surfaces(biome, nodes_or_function_or_model, snodes, checkair)
|
||||
local items_added = 0
|
||||
|
||||
biome_lib:set_defaults(biome)
|
||||
|
||||
@ -351,10 +350,10 @@ function biome_lib:populate_surfaces(biome, nodes_or_function_or_model, snodes,
|
||||
local num_in_biome_nodes = #in_biome_nodes
|
||||
|
||||
if num_in_biome_nodes == 0 then
|
||||
return
|
||||
return 0
|
||||
end
|
||||
|
||||
for i = 1, math.min(biome.max_count, num_in_biome_nodes) do
|
||||
for i = 1, math.min(math.ceil(biome.max_count/25), num_in_biome_nodes) do
|
||||
local tries = 0
|
||||
local spawned = false
|
||||
while tries < 2 and not spawned do
|
||||
@ -423,7 +422,9 @@ function biome_lib:populate_surfaces(biome, nodes_or_function_or_model, snodes,
|
||||
tries = tries + 1
|
||||
end
|
||||
end
|
||||
if spawned then items_added = items_added + 1 end
|
||||
end
|
||||
return items_added
|
||||
end
|
||||
|
||||
-- Primary mapgen spawner, for mods that can work with air checking enabled on
|
||||
@ -446,14 +447,22 @@ function biome_lib:generate_block_with_air_checking()
|
||||
biome_lib.surface_nodes_aircheck.blockhash =
|
||||
minetest.find_nodes_in_area_under_air(minp, maxp, biome_lib.surfaceslist_aircheck)
|
||||
biome_lib.actioncount_aircheck.blockhash = 1
|
||||
|
||||
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 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
|
||||
biome_lib:populate_surfaces(
|
||||
local added = biome_lib:populate_surfaces(
|
||||
biome_lib.actionslist_aircheck[biome_lib.actioncount_aircheck.blockhash][1],
|
||||
biome_lib.actionslist_aircheck[biome_lib.actioncount_aircheck.blockhash][2],
|
||||
biome_lib.surface_nodes_aircheck.blockhash, true)
|
||||
if added > 0 then
|
||||
biome_lib:dbg("Ran biome_lib:populate_surfaces for block at "..minetest.pos_to_string(minp)..
|
||||
". Entry #"..biome_lib.actioncount_aircheck.blockhash.." added "..added.." items.")
|
||||
end
|
||||
biome_lib.actioncount_aircheck.blockhash = biome_lib.actioncount_aircheck.blockhash + 1
|
||||
else
|
||||
table.remove(biome_lib.blocklist_aircheck, 1)
|
||||
@ -480,7 +489,8 @@ function biome_lib:generate_block_no_aircheck()
|
||||
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 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(
|
||||
|
Reference in New Issue
Block a user