Add nil checks

This commit is contained in:
FossFanatic 2023-02-13 15:44:23 +00:00
parent 17cae6896e
commit e17fab385b

View file

@ -803,7 +803,12 @@ end
local grass_spread_randomizer = PseudoRandom(minetest.get_mapgen_setting("seed"))
function mcl_core.get_grass_palette_index(pos)
return mcl_util.get_registered_biome_from_pos(pos)._mcl_grass_palette_index
local reg_biome = mcl_util.get_registered_biome_from_pos(pos)
if reg_biome and reg_biome._mcl_grass_palette_index then
return reg_biome._mcl_grass_palette_index
else
return index
end
end
-- Return appropriate grass block node for pos
@ -812,7 +817,12 @@ function mcl_core.get_grass_block_type(pos)
end
function mcl_core.get_foliage_palette_index(pos)
return mcl_util.get_registered_biome_from_pos(pos)._mcl_foliage_palette_index
local reg_biome = mcl_util.get_registered_biome_from_pos(pos)
if reg_biome and reg_biome._mcl_foliage_palette_index then
return reg_biome._mcl_foliage_palette_index
else
return index
end
end
-- Return appropriate foliage block node for pos