forked from VoxeLibre/VoxeLibre
Fix #3484
If a mob was not found in the spawn_dictionary or the non_spawn dictionary and you tried to use a spawn egg to spawn that mob, the game would crash. This commit prevents that from happening by adding a check for mobs that don't exist, and minetest.log throws an error.
This commit is contained in:
parent
14039290a9
commit
cafc16c41c
|
@ -502,6 +502,7 @@ function mcl_mobs:mob_light_lvl(mob_name, dimension)
|
|||
["max_light"] = spawn_dictionary[i].max_light
|
||||
}
|
||||
end
|
||||
if spawn_dictionary_consolidated[mob_name] ~= nil then
|
||||
mob_dimension = spawn_dictionary_consolidated[mob_name][dimension]
|
||||
mob_dimension_default = spawn_dictionary_consolidated[mob_name]["overworld"]
|
||||
if spawn_dictionary_consolidated[mob_name] == mob_name and mob_dimension ~= nil then
|
||||
|
@ -509,6 +510,12 @@ function mcl_mobs:mob_light_lvl(mob_name, dimension)
|
|||
else
|
||||
return mob_dimension_default.min_light, mob_dimension_default.max_light
|
||||
end
|
||||
else
|
||||
minetest.log("error", "There are no light levels for this mob")
|
||||
--default light values if mob's light values don't exist in either dictionary
|
||||
return 0, minetest.LIGHT_MAX+1
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue