Add second search attempt with less restrictions

master
Wuzzy 2019-08-27 16:40:52 +02:00
parent 192582a997
commit f7e468bc60
1 changed files with 6 additions and 0 deletions

View File

@ -115,6 +115,8 @@ local function find_biome(pos, biomes)
-- Position search
local function search()
local attempt = 1
while attempt < 3 do
for iter = 1, checks do
local biome_data = minetest.get_biome_data(pos)
-- Sometimes biome_data is nil
@ -130,6 +132,8 @@ local function find_biome(pos, biomes)
spawn_pos = {x = spos.x, y = spawn_y, z = spos.z}
elseif not good_spawn_height then
spawn_pos = {x = spos.x, y = spos.y, z = spos.z}
elseif attempt >= 2 then
spawn_pos = {x = spos.x, y = spos.y, z = spos.z}
end
if spawn_pos then
local adjusted_pos, outside = adjust_pos_to_biome_limits(spawn_pos, biome_id)
@ -142,6 +146,8 @@ local function find_biome(pos, biomes)
pos = next_pos()
end
attempt = attempt + 1
end
return false
end