From fbb2923a0b179c9137ed404b178753e43cf2dc49 Mon Sep 17 00:00:00 2001 From: GuyLiner Date: Thu, 9 Feb 2023 21:46:23 -0500 Subject: [PATCH 1/8] Added mcl_mobs:non_spawn_specific function for mobs that don't naturally spawn and for mobs that don't spawn in the overworld --- mods/ENTITIES/mobs_mc/blaze.lua | 3 ++- mods/ENTITIES/mobs_mc/ender_dragon.lua | 1 + mods/ENTITIES/mobs_mc/endermite.lua | 1 + mods/ENTITIES/mobs_mc/ghast.lua | 2 +- mods/ENTITIES/mobs_mc/hoglin+zoglin.lua | 2 ++ mods/ENTITIES/mobs_mc/iron_golem.lua | 1 + mods/ENTITIES/mobs_mc/piglin.lua | 3 ++- mods/ENTITIES/mobs_mc/pillager.lua | 1 + mods/ENTITIES/mobs_mc/shulker.lua | 2 +- mods/ENTITIES/mobs_mc/silverfish.lua | 1 + mods/ENTITIES/mobs_mc/skeleton_wither.lua | 1 + mods/ENTITIES/mobs_mc/slime+magma_cube.lua | 2 +- mods/ENTITIES/mobs_mc/snowman.lua | 1 + mods/ENTITIES/mobs_mc/strider.lua | 1 + mods/ENTITIES/mobs_mc/vex.lua | 1 + mods/ENTITIES/mobs_mc/villager.lua | 1 + mods/ENTITIES/mobs_mc/villager_evoker.lua | 1 + mods/ENTITIES/mobs_mc/villager_illusioner.lua | 1 + mods/ENTITIES/mobs_mc/villager_vindicator.lua | 1 + mods/ENTITIES/mobs_mc/witch.lua | 2 +- mods/ENTITIES/mobs_mc/wither.lua | 1 + mods/ENTITIES/mobs_mc/zombiepig.lua | 1 + 22 files changed, 25 insertions(+), 6 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/blaze.lua b/mods/ENTITIES/mobs_mc/blaze.lua index 18b7ea676..6d92de210 100644 --- a/mods/ENTITIES/mobs_mc/blaze.lua +++ b/mods/ENTITIES/mobs_mc/blaze.lua @@ -207,5 +207,6 @@ mcl_mobs.register_arrow("mobs_mc:blaze_fireball", { end }) --- spawn eggs +mcl_mobs:non_spawn_specific("mobs_mc:blaze", "overworld", 0, 11) +-- spawn eggs. mcl_mobs.register_egg("mobs_mc:blaze", S("Blaze"), "#f6b201", "#fff87e", 0) diff --git a/mods/ENTITIES/mobs_mc/ender_dragon.lua b/mods/ENTITIES/mobs_mc/ender_dragon.lua index ef4c8f811..fb92f51c4 100644 --- a/mods/ENTITIES/mobs_mc/ender_dragon.lua +++ b/mods/ENTITIES/mobs_mc/ender_dragon.lua @@ -174,3 +174,4 @@ mcl_mobs.register_egg("mobs_mc:enderdragon", S("Ender Dragon"), "#252525", "#b31 mcl_wip.register_wip_item("mobs_mc:enderdragon") +mcl_mobs:non_spawn_specific("mobs_mc:enderdragon","overworld",0,minetest.LIGHT_MAX+1) diff --git a/mods/ENTITIES/mobs_mc/endermite.lua b/mods/ENTITIES/mobs_mc/endermite.lua index 612054be8..7542f267b 100644 --- a/mods/ENTITIES/mobs_mc/endermite.lua +++ b/mods/ENTITIES/mobs_mc/endermite.lua @@ -39,3 +39,4 @@ mcl_mobs.register_mob("mobs_mc:endermite", { }) mcl_mobs.register_egg("mobs_mc:endermite", S("Endermite"), "#161616", "#6d6d6d", 0) +mcl_mobs:non_spawn_specific("mobs_mc:endermite","overworld",0,7) diff --git a/mods/ENTITIES/mobs_mc/ghast.lua b/mods/ENTITIES/mobs_mc/ghast.lua index 0f7e73344..1a3d34e1b 100644 --- a/mods/ENTITIES/mobs_mc/ghast.lua +++ b/mods/ENTITIES/mobs_mc/ghast.lua @@ -139,6 +139,6 @@ mcl_mobs.register_arrow("mobs_mc:fireball", { - +mcl_mobs:non_spawn_specific("mobs_mc:ghast","overworld","0","7") -- spawn eggs mcl_mobs.register_egg("mobs_mc:ghast", S("Ghast"), "#f9f9f9", "#bcbcbc", 0) diff --git a/mods/ENTITIES/mobs_mc/hoglin+zoglin.lua b/mods/ENTITIES/mobs_mc/hoglin+zoglin.lua index e5cdcc8a8..1da650812 100644 --- a/mods/ENTITIES/mobs_mc/hoglin+zoglin.lua +++ b/mods/ENTITIES/mobs_mc/hoglin+zoglin.lua @@ -131,5 +131,7 @@ minetest.LIGHT_MAX+1, mcl_vars.mg_nether_min, mcl_vars.mg_nether_max) +mcl_mobs:non_spawn_specific("mobs_mc:hoglin","overworld",0,7) + -- spawn eggs mcl_mobs.register_egg("mobs_mc:hoglin", S("Hoglin"), "#85682e", "#2b2140", 0) diff --git a/mods/ENTITIES/mobs_mc/iron_golem.lua b/mods/ENTITIES/mobs_mc/iron_golem.lua index 34a7a511c..6b428c6f8 100644 --- a/mods/ENTITIES/mobs_mc/iron_golem.lua +++ b/mods/ENTITIES/mobs_mc/iron_golem.lua @@ -206,3 +206,4 @@ function mobs_mc.check_iron_golem_summon(pos) end end end +mcl_mobs:non_spawn_specific("mobs_mc:iron_golem","overworld",0,minetest.LIGHT_MAX+1) diff --git a/mods/ENTITIES/mobs_mc/piglin.lua b/mods/ENTITIES/mobs_mc/piglin.lua index 90e19ef02..055917d8d 100644 --- a/mods/ENTITIES/mobs_mc/piglin.lua +++ b/mods/ENTITIES/mobs_mc/piglin.lua @@ -283,6 +283,7 @@ piglin_brute.group_attack = { "mobs_mc:piglin", "mobs_mc:piglin_brute" } mcl_mobs.register_mob("mobs_mc:piglin_brute", piglin_brute) +mcl_mobs:non_spawn_specific("mobs_mc:piglin","overworld",0,7) -- Regular spawning in the Nether mcl_mobs:spawn_specific( "mobs_mc:piglin", @@ -299,7 +300,7 @@ minetest.LIGHT_MAX+1, 3, mcl_vars.mg_lava_nether_max, mcl_vars.mg_nether_max) - +mcl_mobs:non_spawn_specific("mobs_mc:sword_piglin","overworld",0,7) mcl_mobs:spawn_specific( "mobs_mc:sword_piglin", "nether", diff --git a/mods/ENTITIES/mobs_mc/pillager.lua b/mods/ENTITIES/mobs_mc/pillager.lua index 0b6b036f7..5e07d8dc5 100644 --- a/mods/ENTITIES/mobs_mc/pillager.lua +++ b/mods/ENTITIES/mobs_mc/pillager.lua @@ -122,3 +122,4 @@ pillager = { mcl_mobs.register_mob("mobs_mc:pillager", pillager) mcl_mobs.register_egg("mobs_mc:pillager", S("Pillager"), "#532f36", "#959b9b", 0) +mcl_mobs:non_spawn_specific("mobs_mc:pillager","overworld",0,7) diff --git a/mods/ENTITIES/mobs_mc/shulker.lua b/mods/ENTITIES/mobs_mc/shulker.lua index 46737e90f..ecf60debd 100644 --- a/mods/ENTITIES/mobs_mc/shulker.lua +++ b/mods/ENTITIES/mobs_mc/shulker.lua @@ -178,7 +178,7 @@ mcl_mobs.register_arrow("mobs_mc:shulkerbullet", { mcl_mobs.register_egg("mobs_mc:shulker", S("Shulker"), "#946694", "#4d3852", 0) - +mcl_mobs:non_spawn_specific("mobs_mc:shulker","overworld",0,minetest.LIGHT_MAX+1) --[[ mcl_mobs:spawn_specific( "mobs_mc:shulker", diff --git a/mods/ENTITIES/mobs_mc/silverfish.lua b/mods/ENTITIES/mobs_mc/silverfish.lua index e0bcc23aa..ab659a2a0 100644 --- a/mods/ENTITIES/mobs_mc/silverfish.lua +++ b/mods/ENTITIES/mobs_mc/silverfish.lua @@ -56,3 +56,4 @@ mcl_mobs.register_mob("mobs_mc:silverfish", { }) mcl_mobs.register_egg("mobs_mc:silverfish", S("Silverfish"), "#6d6d6d", "#313131", 0) +mcl_mobs:non_spawn_specific("mobs_mc:silverfish","overworld",0,11) diff --git a/mods/ENTITIES/mobs_mc/skeleton_wither.lua b/mods/ENTITIES/mobs_mc/skeleton_wither.lua index 94fa78120..332b1d56e 100644 --- a/mods/ENTITIES/mobs_mc/skeleton_wither.lua +++ b/mods/ENTITIES/mobs_mc/skeleton_wither.lua @@ -118,3 +118,4 @@ mcl_vars.mg_nether_max) --]] -- spawn eggs mcl_mobs.register_egg("mobs_mc:witherskeleton", S("Wither Skeleton"), "#141414", "#474d4d", 0) +mcl_mobs:non_spawn_specific("mobs_mc:witherskeleton","overworld",0,7) diff --git a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua index 31ecad187..3d0f76486 100644 --- a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua +++ b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua @@ -430,7 +430,7 @@ nether_max) -- spawn eggs mcl_mobs.register_egg("mobs_mc:magma_cube_big", S("Magma Cube"), "#350000", "#fcfc00") - +mcl_mobs:non_spawn_specific("mobs_mc:magma_cube_big","overworld",0, minetest.LIGHT_MAX+1) mcl_mobs.register_egg("mobs_mc:slime_big", S("Slime"), "#52a03e", "#7ebf6d") -- FIXME: add spawn eggs for small and tiny slimes and magma cubes diff --git a/mods/ENTITIES/mobs_mc/snowman.lua b/mods/ENTITIES/mobs_mc/snowman.lua index f9f0043c2..ec2a14675 100644 --- a/mods/ENTITIES/mobs_mc/snowman.lua +++ b/mods/ENTITIES/mobs_mc/snowman.lua @@ -197,3 +197,4 @@ end -- Spawn egg mcl_mobs.register_egg("mobs_mc:snowman", S("Snow Golem"), "#f2f2f2", "#fd8f47", 0) +mcl_mobs:non_spawn_specific("mobs_mc:snowman","overworld",0,minetest.LIGHT_MAX+1) diff --git a/mods/ENTITIES/mobs_mc/strider.lua b/mods/ENTITIES/mobs_mc/strider.lua index a49845f7e..7ea509230 100644 --- a/mods/ENTITIES/mobs_mc/strider.lua +++ b/mods/ENTITIES/mobs_mc/strider.lua @@ -246,3 +246,4 @@ mcl_mobs:spawn_setup({ -- spawn eggs mcl_mobs.register_egg("mobs_mc:strider", S("Strider"), "#000000", "#FF0000", 0) +mcl_mobs:non_spawn_specific("mobs_mc:strider","nether",0,minetest.LIGHT_MAX+1) diff --git a/mods/ENTITIES/mobs_mc/vex.lua b/mods/ENTITIES/mobs_mc/vex.lua index f2cd6f14b..fbb33804d 100644 --- a/mods/ENTITIES/mobs_mc/vex.lua +++ b/mods/ENTITIES/mobs_mc/vex.lua @@ -95,3 +95,4 @@ mcl_mobs.register_mob("mobs_mc:vex", { -- spawn eggs mcl_mobs.register_egg("mobs_mc:vex", S("Vex"), "#7a90a4", "#e8edf1", 0) +mcl_mobs:non_spawn_specific("mobs_mc:vex","overworld",0,7) diff --git a/mods/ENTITIES/mobs_mc/villager.lua b/mods/ENTITIES/mobs_mc/villager.lua index e5aba73e6..48fc353bb 100644 --- a/mods/ENTITIES/mobs_mc/villager.lua +++ b/mods/ENTITIES/mobs_mc/villager.lua @@ -2199,4 +2199,5 @@ mobs_mc.water_level+1, mcl_vars.mg_overworld_max) --]] -- spawn eggs +mcl_mobs:non_spawn_specific("mobs_mc:villager","overworld", 0, minetest.LIGHT_MAX+1) mcl_mobs.register_egg("mobs_mc:villager", S("Villager"), "#563d33", "#bc8b72", 0) diff --git a/mods/ENTITIES/mobs_mc/villager_evoker.lua b/mods/ENTITIES/mobs_mc/villager_evoker.lua index 4d46a7260..a34f0ffe9 100644 --- a/mods/ENTITIES/mobs_mc/villager_evoker.lua +++ b/mods/ENTITIES/mobs_mc/villager_evoker.lua @@ -90,3 +90,4 @@ mcl_mobs.register_mob("mobs_mc:evoker", { -- spawn eggs mcl_mobs.register_egg("mobs_mc:evoker", S("Evoker"), "#959b9b", "#1e1c1a", 0) +mcl_mobs:non_spawn_specific("mobs_mc:evoker","overworld",0,7) diff --git a/mods/ENTITIES/mobs_mc/villager_illusioner.lua b/mods/ENTITIES/mobs_mc/villager_illusioner.lua index f7c034eb0..930a1edfe 100644 --- a/mods/ENTITIES/mobs_mc/villager_illusioner.lua +++ b/mods/ENTITIES/mobs_mc/villager_illusioner.lua @@ -66,3 +66,4 @@ mcl_mobs.register_mob("mobs_mc:illusioner", { }) mcl_mobs.register_egg("mobs_mc:illusioner", S("Illusioner"), "#3f5cbb", "#8a8686", 0) +mcl_mobs:non_spawn_specific("mobs_mc:illusioner","overworld",0,7) diff --git a/mods/ENTITIES/mobs_mc/villager_vindicator.lua b/mods/ENTITIES/mobs_mc/villager_vindicator.lua index b2dcb827a..9ccb8509c 100644 --- a/mods/ENTITIES/mobs_mc/villager_vindicator.lua +++ b/mods/ENTITIES/mobs_mc/villager_vindicator.lua @@ -78,3 +78,4 @@ mcl_mobs.register_mob("mobs_mc:vindicator", { -- spawn eggs mcl_mobs.register_egg("mobs_mc:vindicator", S("Vindicator"), "#959b9b", "#275e61", 0) +mcl_mobs:non_spawn_specific("mobs_mc:vindicator","overworld",0,7) diff --git a/mods/ENTITIES/mobs_mc/witch.lua b/mods/ENTITIES/mobs_mc/witch.lua index 266d5b0c3..b00a68116 100644 --- a/mods/ENTITIES/mobs_mc/witch.lua +++ b/mods/ENTITIES/mobs_mc/witch.lua @@ -106,5 +106,5 @@ mcl_mobs.register_arrow("mobs_mc:potion_arrow", { -- spawn eggs mcl_mobs.register_egg("mobs_mc:witch", S("Witch"), "#340000", "#51a03e", 0, true) - +mcl_mobs:non_spawn_specific("mobs_mc:witch","overworld",0,7) mcl_wip.register_wip_item("mobs_mc:witch") diff --git a/mods/ENTITIES/mobs_mc/wither.lua b/mods/ENTITIES/mobs_mc/wither.lua index dda2beafa..6b47d601a 100644 --- a/mods/ENTITIES/mobs_mc/wither.lua +++ b/mods/ENTITIES/mobs_mc/wither.lua @@ -132,3 +132,4 @@ mcl_mobs.register_arrow("mobs_mc:wither_skull", { mcl_mobs.register_egg("mobs_mc:wither", S("Wither"), "#4f4f4f", "#4f4f4f", 0, true) mcl_wip.register_wip_item("mobs_mc:wither") +mcl_mobs:non_spawn_specific("mobs_mc:wither","overworld",0,minetest.LIGHT_MAX+1) diff --git a/mods/ENTITIES/mobs_mc/zombiepig.lua b/mods/ENTITIES/mobs_mc/zombiepig.lua index 4e89db4f6..f753b5f85 100644 --- a/mods/ENTITIES/mobs_mc/zombiepig.lua +++ b/mods/ENTITIES/mobs_mc/zombiepig.lua @@ -153,3 +153,4 @@ mcl_vars.mg_nether_max) -- spawn eggs mcl_mobs.register_egg("mobs_mc:pigman", S("Zombie Pigman"), "#ea9393", "#4c7129", 0) +mcl_mobs:non_spawn_specific("mobs_mc:pigman","overworld",0,minetest.LIGHT_MAX+1) From 540319d948b02f5103200761051006f70c3b7bc4 Mon Sep 17 00:00:00 2001 From: GuyLiner Date: Thu, 9 Feb 2023 21:47:05 -0500 Subject: [PATCH 2/8] 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? From 0a9be4b79c46dba46c6967cc56527e2f22660499 Mon Sep 17 00:00:00 2001 From: GuyLiner Date: Thu, 9 Feb 2023 21:51:48 -0500 Subject: [PATCH 3/8] Added light level parameters to the mobs_mcl.setup_spawner() function, fixing #221 There is now a call to mcl_mobs:mob_light_lvl that returns a table for the name of the mob that you pass to it that contains the light levels for that mob. --- mods/ENTITIES/mcl_mobs/init.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/init.lua b/mods/ENTITIES/mcl_mobs/init.lua index ed3641dc5..0c7f29b35 100644 --- a/mods/ENTITIES/mcl_mobs/init.lua +++ b/mods/ENTITIES/mcl_mobs/init.lua @@ -489,7 +489,7 @@ function mcl_mobs.register_egg(mob, desc, background_color, overlay_color, addeg on_place = function(itemstack, placer, pointed_thing) local pos = pointed_thing.above - + -- am I clicking on something with existing on_rightclick function? local under = minetest.get_node(pointed_thing.under) local def = minetest.registered_nodes[under.name] @@ -503,6 +503,9 @@ function mcl_mobs.register_egg(mob, desc, background_color, overlay_color, addeg local name = placer:get_player_name() local privs = minetest.get_player_privs(name) + local dim = mcl_worlds.pos_to_dimension(placer:get_pos()) + local mob_light_lvl = mcl_mobs:mob_light_lvl(itemstack:get_name(),dim) + if under.name == "mcl_mobspawners:spawner" then if minetest.is_protected(pointed_thing.under, name) then minetest.record_protection_violation(pointed_thing.under, name) @@ -512,7 +515,8 @@ function mcl_mobs.register_egg(mob, desc, background_color, overlay_color, addeg minetest.chat_send_player(name, S("You need the “maphack” privilege to change the mob spawner.")) return itemstack end - mcl_mobspawners.setup_spawner(pointed_thing.under, itemstack:get_name()) + mcl_mobs:mob_light_lvl(itemstack:get_name(),dim) + mcl_mobspawners.setup_spawner(pointed_thing.under, itemstack:get_name(), mob_light_lvl.min_light, mob_light_lvl.max_light) if not minetest.is_creative_enabled(name) then itemstack:take_item() end From 48b16a23b694a75124d0e53177e7fb28491ed4d1 Mon Sep 17 00:00:00 2001 From: GuyLiner Date: Mon, 6 Feb 2023 09:19:56 -0500 Subject: [PATCH 4/8] If player in creative mode, don't drop experience from destroyed spawners --- mods/ITEMS/mcl_mobspawners/init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_mobspawners/init.lua b/mods/ITEMS/mcl_mobspawners/init.lua index b3cd8a67f..eee6b7600 100644 --- a/mods/ITEMS/mcl_mobspawners/init.lua +++ b/mods/ITEMS/mcl_mobspawners/init.lua @@ -317,7 +317,11 @@ minetest.register_node("mcl_mobspawners:spawner", { if obj then obj:remove() end - mcl_experience.throw_xp(pos, math.random(15, 43)) + --Make sure the player is not in creative mode before + --giving them xp + if not minetest.is_creative_enabled(name) then + mcl_experience.throw_xp(pos, math.random(15, 43)) + end end, on_punch = function(pos) From 3830171347e5cbcfc3d0f07207065872d1b99237 Mon Sep 17 00:00:00 2001 From: GuyLiner Date: Thu, 16 Feb 2023 16:39:59 -0500 Subject: [PATCH 5/8] Adjusted mob_light_lvl for changed return value --- mods/ENTITIES/mcl_mobs/init.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/init.lua b/mods/ENTITIES/mcl_mobs/init.lua index 0c7f29b35..e240cb924 100644 --- a/mods/ENTITIES/mcl_mobs/init.lua +++ b/mods/ENTITIES/mcl_mobs/init.lua @@ -504,8 +504,7 @@ function mcl_mobs.register_egg(mob, desc, background_color, overlay_color, addeg local name = placer:get_player_name() local privs = minetest.get_player_privs(name) local dim = mcl_worlds.pos_to_dimension(placer:get_pos()) - local mob_light_lvl = mcl_mobs:mob_light_lvl(itemstack:get_name(),dim) - + local mob_light_lvl = {mcl_mobs:mob_light_lvl(itemstack:get_name(),dim)} if under.name == "mcl_mobspawners:spawner" then if minetest.is_protected(pointed_thing.under, name) then minetest.record_protection_violation(pointed_thing.under, name) @@ -515,8 +514,7 @@ function mcl_mobs.register_egg(mob, desc, background_color, overlay_color, addeg minetest.chat_send_player(name, S("You need the “maphack” privilege to change the mob spawner.")) return itemstack end - mcl_mobs:mob_light_lvl(itemstack:get_name(),dim) - mcl_mobspawners.setup_spawner(pointed_thing.under, itemstack:get_name(), mob_light_lvl.min_light, mob_light_lvl.max_light) + mcl_mobspawners.setup_spawner(pointed_thing.under, itemstack:get_name(), mob_light_lvl[1], mob_light_lvl[2]) if not minetest.is_creative_enabled(name) then itemstack:take_item() end From cd1c8bd92ea724f3319f8c84c8968be52b65521c Mon Sep 17 00:00:00 2001 From: GuyLiner Date: Thu, 16 Feb 2023 16:46:41 -0500 Subject: [PATCH 6/8] Refactored logic for getting light levels for mobs Removed mob_light_table, simplied loop, changed return values and fixed dimension priority error in loop. Slimes also don't have a hardcoded exception for their light levels anymore, and instead are apart of spawn specific. --- mods/ENTITIES/mcl_mobs/spawning.lua | 55 ++++++++++------------------- 1 file changed, 19 insertions(+), 36 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/spawning.lua index 891cd518d..507652a95 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -481,51 +481,34 @@ function mcl_mobs:spawn_setup(def) end function mcl_mobs:mob_light_lvl(mob_name, dimension) - local mob_light_table = {} + local spawn_dictionary_consolidated = {} --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 + local mob_dimension = non_spawn_dictionary[mob_name][dimension] + if mob_name ~= nil then + return mob_dimension.min_light,mob_dimension.max_light 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 + return non_spawn_dictionary[mob_name]["overworld"].min_light, non_spawn_dictionary[mob_name]["overworld"].max_light 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 + if spawn_dictionary[spawn_dictionary[i].name] == nil then + spawn_dictionary_consolidated[spawn_dictionary[i].name] = {} + end + spawn_dictionary_consolidated[spawn_dictionary[i].name][dimension] = { + ["min_light"] = spawn_dictionary[i].min_light, + ["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 + else + return mob_dimension_default.min_light, mob_dimension_default.max_light + end end end From e99a46b52d311bc2e222fc545ee5656eccc9d4f7 Mon Sep 17 00:00:00 2001 From: GuyLiner Date: Thu, 16 Feb 2023 16:47:02 -0500 Subject: [PATCH 7/8] Removed comment --- mods/ITEMS/mcl_mobspawners/init.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/mods/ITEMS/mcl_mobspawners/init.lua b/mods/ITEMS/mcl_mobspawners/init.lua index eee6b7600..4862afe02 100644 --- a/mods/ITEMS/mcl_mobspawners/init.lua +++ b/mods/ITEMS/mcl_mobspawners/init.lua @@ -317,8 +317,6 @@ minetest.register_node("mcl_mobspawners:spawner", { if obj then obj:remove() end - --Make sure the player is not in creative mode before - --giving them xp if not minetest.is_creative_enabled(name) then mcl_experience.throw_xp(pos, math.random(15, 43)) end From f39cec2442408317ecfd9d91ed3e1d302809af6d Mon Sep 17 00:00:00 2001 From: GuyLiner Date: Thu, 16 Feb 2023 18:57:46 -0500 Subject: [PATCH 8/8] Added slime_big to non_spawn_specific instead of creating an exception for them in spawning.lua --- mods/ENTITIES/mobs_mc/slime+magma_cube.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua index 3d0f76486..e9fa340e3 100644 --- a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua +++ b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua @@ -278,7 +278,6 @@ swamp_light_max, 4, swamp_min, swamp_max) - -- Magma cube local magma_cube_big = { description = S("Magma Cube"), @@ -430,6 +429,11 @@ nether_max) -- spawn eggs mcl_mobs.register_egg("mobs_mc:magma_cube_big", S("Magma Cube"), "#350000", "#fcfc00") + +-- non_spawn_specific is typically for mobs who don't spawn in the overworld, or mobs that don't spawn +-- naturally. However, slimes are a particular case where they spawn under different conditions in the same +-- dimension. +mcl_mobs:non_spawn_specific("mobs_mc:slime_big","overworld",0,minetest.LIGHT_MAX+1) mcl_mobs:non_spawn_specific("mobs_mc:magma_cube_big","overworld",0, minetest.LIGHT_MAX+1) mcl_mobs.register_egg("mobs_mc:slime_big", S("Slime"), "#52a03e", "#7ebf6d")