mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2025-03-11 06:07:44 +01:00
Fix crash in skyblock spawning (#4905)
Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4905 Reviewed-by: kno10 <kno10@noreply.git.minetest.land> Co-authored-by: teknomunk <teknomunk@protonmail.com> Co-committed-by: teknomunk <teknomunk@protonmail.com>
This commit is contained in:
parent
da7cf8a723
commit
15ed7895cd
1 changed files with 16 additions and 1 deletions
|
@ -526,8 +526,23 @@ function mcl_mobs.register_custom_biomecheck(custom_biomecheck)
|
|||
mcl_mobs.custom_biomecheck = custom_biomecheck
|
||||
end
|
||||
|
||||
local custom_biome_ids = {}
|
||||
local custom_biome_names = {}
|
||||
local next_custom_biome_id = 0
|
||||
|
||||
local function get_biome_name(pos)
|
||||
if mcl_mobs.custom_biomecheck then return mcl_mobs.custom_biomecheck(pos) end
|
||||
if mcl_mobs.custom_biomecheck then
|
||||
local biome_name = mcl_mobs.custom_biomecheck(pos)
|
||||
local biome_id = custom_biome_ids[biome_name]
|
||||
if not biome_id then
|
||||
biome_id = next_custom_biome_id
|
||||
next_custom_biome_name = biome_id + 1
|
||||
|
||||
custom_biome_ids[biome_name] = biome_id
|
||||
custom_biome_names[biome_id] = biome_name
|
||||
end
|
||||
return biome_name, biome_id
|
||||
end
|
||||
local biome_data = core.get_biome_data(pos)
|
||||
local biome_id = biome_data and biome_data.biome
|
||||
local biome_name = biome_id and mt_get_biome_name(biome_id)
|
||||
|
|
Loading…
Reference in a new issue