diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/spawning.lua index ac30614cc..fdafb0348 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -30,11 +30,13 @@ local dbg_spawn_counts = {} local aoc_range = 136 local mob_cap = { - monster = minetest.settings:get_bool("mcl_mob_cap_monster") or 70, - animal = minetest.settings:get_bool("mcl_mob_cap_animal") or 10, - ambient = minetest.settings:get_bool("mcl_mob_cap_ambient") or 15, - water = minetest.settings:get_bool("mcl_mob_cap_water") or 5, --currently unused - water_ambient = minetest.settings:get_bool("mcl_mob_cap_water_ambient") or 20, --currently unused + monster = tonumber(minetest.settings:get("mcl_mob_cap_monster")) or 70, + animal = tonumber(minetest.settings:get("mcl_mob_cap_animal")) or 10, + ambient = tonumber(minetest.settings:get("mcl_mob_cap_ambient")) or 15, + water = tonumber(minetest.settings:get("mcl_mob_cap_water")) or 5, --currently unused + water_ambient = tonumber(minetest.settings:get("mcl_mob_cap_water_ambient")) or 20, --currently unused + player = tonumber(minetest.settings:get("mcl_mob_cap_player")) or 75, + total = tonumber(minetest.settings:get("mcl_mob_cap_total")) or 500, } --do mobs spawn? @@ -664,7 +666,13 @@ if mobs_spawn then timer = timer + dtime if timer < 10 then return end timer = 0 - for _, player in pairs(get_connected_players()) do + local players = get_connected_players() + local total_mobs = count_mobs_total() + if total_mobs > mob_cap.total or total_mobs > #players * mob_cap.player then + minetest.log("warning","[mcl_mobs] mob cap reached. no cycle spawning.") + return + end --mob cap per player + for _, player in pairs(players) do local pos = player:get_pos() local dimension = mcl_worlds.pos_to_dimension(pos) -- ignore void and unloaded area diff --git a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua index f1d1da46e..eebe16f98 100644 --- a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua +++ b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua @@ -11,6 +11,8 @@ local cow_def = { xp_min = 1, xp_max = 3, collisionbox = {-0.45, -0.01, -0.45, 0.45, 1.39, 0.45}, + spawn_in_group = 8, + spawn_in_group_min = 3, visual = "mesh", mesh = "mobs_mc_cow.b3d", textures = { { diff --git a/settingtypes.txt b/settingtypes.txt index 0265778b6..97464d79c 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -99,6 +99,12 @@ mobs_griefing (Mobs change blocks) bool true # If enabled, mobs won't damage particles when they got hurt. mobs_disable_blood (Disable mob damage particles) bool false +#Maximum amount mobs (default:500) +mcl_mob_cap_total (Global mob cap) int 500 0 2048 + +#Maximum amount of mobs per player (default:75) +mcl_mob_cap_player (Mob cap per player) int 75 0 2048 + #Maximum amount of monsters that will spawn near a player (default:70) mcl_mob_cap_monster (Mob cap monsters) int 70 0 2048