1
0
Fork 0
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,6 +502,7 @@ function mcl_mobs:mob_light_lvl(mob_name, dimension)
["max_light"] = spawn_dictionary[i].max_light ["max_light"] = spawn_dictionary[i].max_light
} }
end end
if spawn_dictionary_consolidated[mob_name] ~= nil then
mob_dimension = spawn_dictionary_consolidated[mob_name][dimension] mob_dimension = spawn_dictionary_consolidated[mob_name][dimension]
mob_dimension_default = spawn_dictionary_consolidated[mob_name]["overworld"] mob_dimension_default = spawn_dictionary_consolidated[mob_name]["overworld"]
if spawn_dictionary_consolidated[mob_name] == mob_name and mob_dimension ~= nil then 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 else
return mob_dimension_default.min_light, mob_dimension_default.max_light return mob_dimension_default.min_light, mob_dimension_default.max_light
end 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
end end