forked from VoxeLibre/VoxeLibre
Merge pull request 'Fix custom spawners spawning mobs regardless of light level' (#3421) from GuyLiner/MineClone2:fix-spawner into master
Reviewed-on: MineClone2/MineClone2#3421 Reviewed-by: ancientmarinerdev <ancientmariner_dev@proton.me>
This commit is contained in:
commit
e8641c3c20
|
@ -489,7 +489,7 @@ function mcl_mobs.register_egg(mob, desc, background_color, overlay_color, addeg
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
|
||||||
local pos = pointed_thing.above
|
local pos = pointed_thing.above
|
||||||
|
|
||||||
-- am I clicking on something with existing on_rightclick function?
|
-- am I clicking on something with existing on_rightclick function?
|
||||||
local under = minetest.get_node(pointed_thing.under)
|
local under = minetest.get_node(pointed_thing.under)
|
||||||
local def = minetest.registered_nodes[under.name]
|
local def = minetest.registered_nodes[under.name]
|
||||||
|
@ -503,6 +503,8 @@ function mcl_mobs.register_egg(mob, desc, background_color, overlay_color, addeg
|
||||||
|
|
||||||
local name = placer:get_player_name()
|
local name = placer:get_player_name()
|
||||||
local privs = minetest.get_player_privs(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 under.name == "mcl_mobspawners:spawner" then
|
||||||
if minetest.is_protected(pointed_thing.under, name) then
|
if minetest.is_protected(pointed_thing.under, name) then
|
||||||
minetest.record_protection_violation(pointed_thing.under, name)
|
minetest.record_protection_violation(pointed_thing.under, name)
|
||||||
|
@ -512,7 +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."))
|
minetest.chat_send_player(name, S("You need the “maphack” privilege to change the mob spawner."))
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
mcl_mobspawners.setup_spawner(pointed_thing.under, itemstack:get_name())
|
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
|
if not minetest.is_creative_enabled(name) then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
|
|
|
@ -413,6 +413,8 @@ WARNING: BIOME INTEGRATION NEEDED -> How to get biome through lua??
|
||||||
|
|
||||||
--this is where all of the spawning information is kept
|
--this is where all of the spawning information is kept
|
||||||
local spawn_dictionary = {}
|
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
|
local summary_chance = 0
|
||||||
|
|
||||||
function mcl_mobs:spawn_setup(def)
|
function mcl_mobs:spawn_setup(def)
|
||||||
|
@ -478,6 +480,47 @@ function mcl_mobs:spawn_setup(def)
|
||||||
summary_chance = summary_chance + chance
|
summary_chance = summary_chance + chance
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mcl_mobs:mob_light_lvl(mob_name, dimension)
|
||||||
|
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
|
||||||
|
local mob_dimension = non_spawn_dictionary[mob_name][dimension]
|
||||||
|
if mob_name ~= nil then
|
||||||
|
return mob_dimension.min_light,mob_dimension.max_light
|
||||||
|
else
|
||||||
|
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
|
||||||
|
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
|
||||||
|
|
||||||
|
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)
|
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?
|
-- Do mobs spawn at all?
|
||||||
|
|
|
@ -207,5 +207,6 @@ mcl_mobs.register_arrow("mobs_mc:blaze_fireball", {
|
||||||
end
|
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)
|
mcl_mobs.register_egg("mobs_mc:blaze", S("Blaze"), "#f6b201", "#fff87e", 0)
|
||||||
|
|
|
@ -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_wip.register_wip_item("mobs_mc:enderdragon")
|
||||||
|
mcl_mobs:non_spawn_specific("mobs_mc:enderdragon","overworld",0,minetest.LIGHT_MAX+1)
|
||||||
|
|
|
@ -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.register_egg("mobs_mc:endermite", S("Endermite"), "#161616", "#6d6d6d", 0)
|
||||||
|
mcl_mobs:non_spawn_specific("mobs_mc:endermite","overworld",0,7)
|
||||||
|
|
|
@ -139,6 +139,6 @@ mcl_mobs.register_arrow("mobs_mc:fireball", {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mcl_mobs:non_spawn_specific("mobs_mc:ghast","overworld","0","7")
|
||||||
-- spawn eggs
|
-- spawn eggs
|
||||||
mcl_mobs.register_egg("mobs_mc:ghast", S("Ghast"), "#f9f9f9", "#bcbcbc", 0)
|
mcl_mobs.register_egg("mobs_mc:ghast", S("Ghast"), "#f9f9f9", "#bcbcbc", 0)
|
||||||
|
|
|
@ -131,5 +131,7 @@ minetest.LIGHT_MAX+1,
|
||||||
mcl_vars.mg_nether_min,
|
mcl_vars.mg_nether_min,
|
||||||
mcl_vars.mg_nether_max)
|
mcl_vars.mg_nether_max)
|
||||||
|
|
||||||
|
mcl_mobs:non_spawn_specific("mobs_mc:hoglin","overworld",0,7)
|
||||||
|
|
||||||
-- spawn eggs
|
-- spawn eggs
|
||||||
mcl_mobs.register_egg("mobs_mc:hoglin", S("Hoglin"), "#85682e", "#2b2140", 0)
|
mcl_mobs.register_egg("mobs_mc:hoglin", S("Hoglin"), "#85682e", "#2b2140", 0)
|
||||||
|
|
|
@ -206,3 +206,4 @@ function mobs_mc.check_iron_golem_summon(pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
mcl_mobs:non_spawn_specific("mobs_mc:iron_golem","overworld",0,minetest.LIGHT_MAX+1)
|
||||||
|
|
|
@ -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.register_mob("mobs_mc:piglin_brute", piglin_brute)
|
||||||
|
|
||||||
|
|
||||||
|
mcl_mobs:non_spawn_specific("mobs_mc:piglin","overworld",0,7)
|
||||||
-- Regular spawning in the Nether
|
-- Regular spawning in the Nether
|
||||||
mcl_mobs:spawn_specific(
|
mcl_mobs:spawn_specific(
|
||||||
"mobs_mc:piglin",
|
"mobs_mc:piglin",
|
||||||
|
@ -299,7 +300,7 @@ minetest.LIGHT_MAX+1,
|
||||||
3,
|
3,
|
||||||
mcl_vars.mg_lava_nether_max,
|
mcl_vars.mg_lava_nether_max,
|
||||||
mcl_vars.mg_nether_max)
|
mcl_vars.mg_nether_max)
|
||||||
|
mcl_mobs:non_spawn_specific("mobs_mc:sword_piglin","overworld",0,7)
|
||||||
mcl_mobs:spawn_specific(
|
mcl_mobs:spawn_specific(
|
||||||
"mobs_mc:sword_piglin",
|
"mobs_mc:sword_piglin",
|
||||||
"nether",
|
"nether",
|
||||||
|
|
|
@ -122,3 +122,4 @@ pillager = {
|
||||||
|
|
||||||
mcl_mobs.register_mob("mobs_mc:pillager", pillager)
|
mcl_mobs.register_mob("mobs_mc:pillager", pillager)
|
||||||
mcl_mobs.register_egg("mobs_mc:pillager", S("Pillager"), "#532f36", "#959b9b", 0)
|
mcl_mobs.register_egg("mobs_mc:pillager", S("Pillager"), "#532f36", "#959b9b", 0)
|
||||||
|
mcl_mobs:non_spawn_specific("mobs_mc:pillager","overworld",0,7)
|
||||||
|
|
|
@ -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.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(
|
mcl_mobs:spawn_specific(
|
||||||
"mobs_mc:shulker",
|
"mobs_mc:shulker",
|
||||||
|
|
|
@ -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.register_egg("mobs_mc:silverfish", S("Silverfish"), "#6d6d6d", "#313131", 0)
|
||||||
|
mcl_mobs:non_spawn_specific("mobs_mc:silverfish","overworld",0,11)
|
||||||
|
|
|
@ -118,3 +118,4 @@ mcl_vars.mg_nether_max)
|
||||||
--]]
|
--]]
|
||||||
-- spawn eggs
|
-- spawn eggs
|
||||||
mcl_mobs.register_egg("mobs_mc:witherskeleton", S("Wither Skeleton"), "#141414", "#474d4d", 0)
|
mcl_mobs.register_egg("mobs_mc:witherskeleton", S("Wither Skeleton"), "#141414", "#474d4d", 0)
|
||||||
|
mcl_mobs:non_spawn_specific("mobs_mc:witherskeleton","overworld",0,7)
|
||||||
|
|
|
@ -278,7 +278,6 @@ swamp_light_max,
|
||||||
4,
|
4,
|
||||||
swamp_min,
|
swamp_min,
|
||||||
swamp_max)
|
swamp_max)
|
||||||
|
|
||||||
-- Magma cube
|
-- Magma cube
|
||||||
local magma_cube_big = {
|
local magma_cube_big = {
|
||||||
description = S("Magma Cube"),
|
description = S("Magma Cube"),
|
||||||
|
@ -431,6 +430,11 @@ nether_max)
|
||||||
-- spawn eggs
|
-- spawn eggs
|
||||||
mcl_mobs.register_egg("mobs_mc:magma_cube_big", S("Magma Cube"), "#350000", "#fcfc00")
|
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")
|
mcl_mobs.register_egg("mobs_mc:slime_big", S("Slime"), "#52a03e", "#7ebf6d")
|
||||||
|
|
||||||
-- FIXME: add spawn eggs for small and tiny slimes and magma cubes
|
-- FIXME: add spawn eggs for small and tiny slimes and magma cubes
|
||||||
|
|
|
@ -197,3 +197,4 @@ end
|
||||||
|
|
||||||
-- Spawn egg
|
-- Spawn egg
|
||||||
mcl_mobs.register_egg("mobs_mc:snowman", S("Snow Golem"), "#f2f2f2", "#fd8f47", 0)
|
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)
|
||||||
|
|
|
@ -246,3 +246,4 @@ mcl_mobs:spawn_setup({
|
||||||
|
|
||||||
-- spawn eggs
|
-- spawn eggs
|
||||||
mcl_mobs.register_egg("mobs_mc:strider", S("Strider"), "#000000", "#FF0000", 0)
|
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)
|
||||||
|
|
|
@ -95,3 +95,4 @@ mcl_mobs.register_mob("mobs_mc:vex", {
|
||||||
|
|
||||||
-- spawn eggs
|
-- spawn eggs
|
||||||
mcl_mobs.register_egg("mobs_mc:vex", S("Vex"), "#7a90a4", "#e8edf1", 0)
|
mcl_mobs.register_egg("mobs_mc:vex", S("Vex"), "#7a90a4", "#e8edf1", 0)
|
||||||
|
mcl_mobs:non_spawn_specific("mobs_mc:vex","overworld",0,7)
|
||||||
|
|
|
@ -2199,4 +2199,5 @@ mobs_mc.water_level+1,
|
||||||
mcl_vars.mg_overworld_max)
|
mcl_vars.mg_overworld_max)
|
||||||
--]]
|
--]]
|
||||||
-- spawn eggs
|
-- 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)
|
mcl_mobs.register_egg("mobs_mc:villager", S("Villager"), "#563d33", "#bc8b72", 0)
|
||||||
|
|
|
@ -90,3 +90,4 @@ mcl_mobs.register_mob("mobs_mc:evoker", {
|
||||||
|
|
||||||
-- spawn eggs
|
-- spawn eggs
|
||||||
mcl_mobs.register_egg("mobs_mc:evoker", S("Evoker"), "#959b9b", "#1e1c1a", 0)
|
mcl_mobs.register_egg("mobs_mc:evoker", S("Evoker"), "#959b9b", "#1e1c1a", 0)
|
||||||
|
mcl_mobs:non_spawn_specific("mobs_mc:evoker","overworld",0,7)
|
||||||
|
|
|
@ -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.register_egg("mobs_mc:illusioner", S("Illusioner"), "#3f5cbb", "#8a8686", 0)
|
||||||
|
mcl_mobs:non_spawn_specific("mobs_mc:illusioner","overworld",0,7)
|
||||||
|
|
|
@ -78,3 +78,4 @@ mcl_mobs.register_mob("mobs_mc:vindicator", {
|
||||||
|
|
||||||
-- spawn eggs
|
-- spawn eggs
|
||||||
mcl_mobs.register_egg("mobs_mc:vindicator", S("Vindicator"), "#959b9b", "#275e61", 0)
|
mcl_mobs.register_egg("mobs_mc:vindicator", S("Vindicator"), "#959b9b", "#275e61", 0)
|
||||||
|
mcl_mobs:non_spawn_specific("mobs_mc:vindicator","overworld",0,7)
|
||||||
|
|
|
@ -106,5 +106,5 @@ mcl_mobs.register_arrow("mobs_mc:potion_arrow", {
|
||||||
|
|
||||||
-- spawn eggs
|
-- spawn eggs
|
||||||
mcl_mobs.register_egg("mobs_mc:witch", S("Witch"), "#340000", "#51a03e", 0, true)
|
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")
|
mcl_wip.register_wip_item("mobs_mc:witch")
|
||||||
|
|
|
@ -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_mobs.register_egg("mobs_mc:wither", S("Wither"), "#4f4f4f", "#4f4f4f", 0, true)
|
||||||
|
|
||||||
mcl_wip.register_wip_item("mobs_mc:wither")
|
mcl_wip.register_wip_item("mobs_mc:wither")
|
||||||
|
mcl_mobs:non_spawn_specific("mobs_mc:wither","overworld",0,minetest.LIGHT_MAX+1)
|
||||||
|
|
|
@ -153,3 +153,4 @@ mcl_vars.mg_nether_max)
|
||||||
|
|
||||||
-- spawn eggs
|
-- spawn eggs
|
||||||
mcl_mobs.register_egg("mobs_mc:pigman", S("Zombie Pigman"), "#ea9393", "#4c7129", 0)
|
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)
|
||||||
|
|
|
@ -317,7 +317,9 @@ minetest.register_node("mcl_mobspawners:spawner", {
|
||||||
if obj then
|
if obj then
|
||||||
obj:remove()
|
obj:remove()
|
||||||
end
|
end
|
||||||
mcl_experience.throw_xp(pos, math.random(15, 43))
|
if not minetest.is_creative_enabled(name) then
|
||||||
|
mcl_experience.throw_xp(pos, math.random(15, 43))
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_punch = function(pos)
|
on_punch = function(pos)
|
||||||
|
|
Loading…
Reference in New Issue