From 540319d948b02f5103200761051006f70c3b7bc4 Mon Sep 17 00:00:00 2001 From: GuyLiner Date: Thu, 9 Feb 2023 21:47:05 -0500 Subject: [PATCH] Added non_spawn_dictionary and function for getting mob light levels The non_spawn_dictionary will cover all mobs that don't spawn naturally, and holds the the minimum and maximum light values for each of them. A function has also been created that will go through both the spawn_dictionary and the non_spawn_dictionary and determine which one a mob exists in, with the execption of slimes which cannot spawn from a custom spawner at the moment. Mobs who don't have light levels for the world that you are currently trying to set your custom spawner in will default to their overworld values --- mods/ENTITIES/mcl_mobs/spawning.lua | 60 +++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/spawning.lua index 438935d70..891cd518d 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -413,6 +413,8 @@ WARNING: BIOME INTEGRATION NEEDED -> How to get biome through lua?? --this is where all of the spawning information is kept local spawn_dictionary = {} +--this is where all of the spawning information is kept for mobs that don't naturally spawn +local non_spawn_dictionary = {} local summary_chance = 0 function mcl_mobs:spawn_setup(def) @@ -478,6 +480,64 @@ function mcl_mobs:spawn_setup(def) summary_chance = summary_chance + chance end +function mcl_mobs:mob_light_lvl(mob_name, dimension) + local mob_light_table = {} + --see if the mob exists in the nonspawn dictionary, if so then return light values + if non_spawn_dictionary[mob_name] ~= nil then + if non_spawn_dictionary[mob_name][dimension] ~= nil then + mob_light_table = { + ["min_light"] = non_spawn_dictionary[mob_name][dimension].min_light, + ["max_light"] = non_spawn_dictionary[mob_name][dimension].max_light + } + return mob_light_table + else + mob_light_table = { + ["min_light"] = non_spawn_dictionary[mob_name]["overworld"].min_light, + ["max_light"] = non_spawn_dictionary[mob_name]["overworld"].max_light + } + return mob_light_table + end + + --if the mob doesn't exist in non_spawn, check spawn_dictonary + else + for i,v in pairs(spawn_dictionary) do + local big_slime_search = string.find(spawn_dictionary[i].name,".*slime.*") + if spawn_dictionary[i].name == mob_name and spawn_dictionary[i].dimension == dimension and not big_slime_search then + mob_light_table = { + ["min_light"] = spawn_dictionary[i].min_light, + ["max_light"] = spawn_dictionary[i].max_light + } + return mob_light_table + + elseif spawn_dictionary[i].name == mob_name and spawn_dictionary[i].dimension == "overworld" and not big_slime_search then + mob_light_table = { + ["min_light"] = spawn_dictionary[i].min_light, + ["max_light"] = spawn_dictionary[i].max_light + } + return mob_light_table + elseif big_slime_search then + --custom spawners with slimes are broken in minecraft (they don't spawn unless in slime chunk) so we'll make sure they're broken in mcl2 as well :) + --if slimes chunks get added in the future, change this. + --Mobs will also have their light levels set to this for custom spawners if they don't appear in spawn_dictionary or non_spawn_dictionary + mob_light_table = { + ["min_light"] = -1, + ["max_light"] = -1 + } + return mob_light_table + end + end + end +end + +function mcl_mobs:non_spawn_specific(mob_name,dimension,min_light,max_light) + table.insert(non_spawn_dictionary, mob_name) + non_spawn_dictionary[mob_name] = { + [dimension] = { + min_light = min_light , max_light = max_light + } + } +end + function mcl_mobs:spawn_specific(name, dimension, type_of_spawning, biomes, min_light, max_light, interval, chance, aoc, min_height, max_height, day_toggle, on_spawn) -- Do mobs spawn at all?