diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 84b24c339c..998b055473 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -4036,6 +4036,7 @@ minetest.register_entity(name, { fire_resistant = def.fire_resistant or false, fire_damage_resistant = def.fire_damage_resistant or false, ignited_by_sunlight = def.ignited_by_sunlight or false, + spawn_in_group = def.spawn_in_group, -- End of MCL2 extensions on_spawn = def.on_spawn, diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/spawning.lua index f8c94afb67..a1c8e23b5f 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -386,6 +386,13 @@ local function get_water_spawn(p) end end +local function spawn_group(p,mob,spawn_on,group_max) + local nn = minetest.find_nodes_in_area(vector.offset(p,-3,-3,-3),vector.offset(p,3,3,3),spawn_on) + for i = 1, math.random(group_max) do + minetest.add_entity(nn[math.random(#nn)],mob) + end +end + if mobs_spawn then local perlin_noise @@ -449,6 +456,7 @@ if mobs_spawn then end local mob_def = mob_library_worker_table[mob_index] local mob_type = minetest.registered_entities[mob_def.name].type + local spawn_in_group = minetest.registered_entities[mob_def.name].spawn_in_group if mob_def and spawning_position.y >= mob_def.min_height and spawning_position.y <= mob_def.max_height @@ -470,6 +478,9 @@ if mobs_spawn then end --everything is correct, spawn mob local object = minetest.add_entity(spawning_position, mob_def.name) + if spawn_in_group then + spawn_group(spawning_position,mob_def.name,{gotten_node},spawn_in_group) + end if object then return mob_def.on_spawn and mob_def.on_spawn(object, spawning_position) end diff --git a/mods/ENTITIES/mobs_mc/cod.lua b/mods/ENTITIES/mobs_mc/cod.lua index 0d40912dc1..11c6ee01fe 100644 --- a/mods/ENTITIES/mobs_mc/cod.lua +++ b/mods/ENTITIES/mobs_mc/cod.lua @@ -40,6 +40,7 @@ local cod = { xp_max = 3, armor = 100, rotate = 180, + spawn_in_group = 10, tilt_swim = true, collisionbox = {-0.3, 0.0, -0.3, 0.3, 0.79, 0.3}, visual = "mesh", diff --git a/mods/ENTITIES/mobs_mc/dolphin.lua b/mods/ENTITIES/mobs_mc/dolphin.lua index f991e74957..333da38083 100644 --- a/mods/ENTITIES/mobs_mc/dolphin.lua +++ b/mods/ENTITIES/mobs_mc/dolphin.lua @@ -42,6 +42,7 @@ local dolphin = { walk_chance = 100, breath_max = 120, rotate = 180, + spawn_in_group = 3, tilt_swim = true, collisionbox = {-0.3, 0.0, -0.3, 0.3, 0.79, 0.3}, visual = "mesh", diff --git a/mods/ENTITIES/mobs_mc/salmon.lua b/mods/ENTITIES/mobs_mc/salmon.lua index b586918fb6..dea502fd05 100644 --- a/mods/ENTITIES/mobs_mc/salmon.lua +++ b/mods/ENTITIES/mobs_mc/salmon.lua @@ -19,6 +19,7 @@ local salmon = { xp_min = 1, xp_max = 3, armor = 100, + spawn_in_group = 5, tilt_swim = true, collisionbox = {-0.4, 0.0, -0.4, 0.4, 0.79, 0.4}, visual = "mesh",