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:
GuyLiner 2023-02-26 11:22:21 -05:00
parent 14039290a9
commit cafc16c41c
1 changed files with 14 additions and 7 deletions

View File

@ -502,13 +502,20 @@ function mcl_mobs:mob_light_lvl(mob_name, dimension)
["max_light"] = spawn_dictionary[i].max_light
}
end
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
return mob_dimension.min_light, mob_dimension.max_light
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
return mob_dimension.min_light, mob_dimension.max_light
else
return mob_dimension_default.min_light, mob_dimension_default.max_light
end
else
return mob_dimension_default.min_light, mob_dimension_default.max_light
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