From a077e4535fc173bda23013b71d65f98117b9d2fb Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 17 Jul 2022 00:32:06 +0200 Subject: [PATCH 01/10] Fix non-monsters being unable to attack A check in the relevant function excluded all non-monsters from looking for targets to attack. This removes that check and relies on the passive attribute of the entity --- mods/ENTITIES/mcl_mobs/api.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 5485e7cc1..61bed6901 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -1905,11 +1905,10 @@ local specific_attack = function(list, what) return false end --- monster find someone to attack +-- find someone to attack local monster_attack = function(self) - if self.type ~= "monster" - or not damage_enabled + if not damage_enabled or minetest.is_creative_enabled("") or self.passive or self.state == "attack" From a68343b71d7625e31e57adcbce4a82061b1eb54f Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 17 Jul 2022 02:20:12 +0200 Subject: [PATCH 02/10] Add group spawning minimum attribute --- mods/ENTITIES/mcl_mobs/spawning.lua | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/spawning.lua index 2108ecf41..b3de6f50f 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -386,15 +386,18 @@ 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) +local function spawn_group(p,mob,spawn_on,group_max,group_min) + if not group_min then group_min = 1 end + local nn = minetest.find_nodes_in_area(vector.offset(p,-5,-3,-5),vector.offset(p,5,3,5),spawn_on) + local o if not nn or #nn < 1 then nn = {} table.insert(nn,p) end - for i = 1, math.random(group_max) do - minetest.add_entity(nn[math.random(#nn)],mob) + for i = 1, math.random(group_min,group_max) do + o = minetest.add_entity(nn[math.random(#nn)],mob) end + return o end if mobs_spawn then @@ -461,7 +464,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 + local spawn_in_group = minetest.registered_entities[mob_def.name].spawn_in_group or 4 if mob_def and spawning_position.y >= mob_def.min_height and spawning_position.y <= mob_def.max_height @@ -483,10 +486,13 @@ if mobs_spawn then end end --everything is correct, spawn mob - local object = minetest.add_entity(spawning_position, mob_def.name) + local object if spawn_in_group then - spawn_group(spawning_position,mob_def.name,{gotten_node},spawn_in_group) + object = spawn_group(spawning_position,mob_def.name,{gotten_node},spawn_in_group,spawn_in_group_min) + else object = minetest.add_entity(spawning_position, mob_def.name) end + + if object then return mob_def.on_spawn and mob_def.on_spawn(object, spawning_position) end From 9883a37754e9479adeb2dfd554ec05b2362efca8 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 17 Jul 2022 02:20:51 +0200 Subject: [PATCH 03/10] Enable group spawning for all mobs, add mc values --- mods/ENTITIES/mobs_mc/bat.lua | 1 + mods/ENTITIES/mobs_mc/blaze.lua | 2 ++ mods/ENTITIES/mobs_mc/cod.lua | 3 ++- mods/ENTITIES/mobs_mc/cow+mooshroom.lua | 2 ++ mods/ENTITIES/mobs_mc/ghast.lua | 1 + mods/ENTITIES/mobs_mc/guardian.lua | 4 +++- mods/ENTITIES/mobs_mc/horse.lua | 4 ++++ mods/ENTITIES/mobs_mc/llama.lua | 2 ++ mods/ENTITIES/mobs_mc/ocelot.lua | 2 ++ mods/ENTITIES/mobs_mc/rabbit.lua | 3 ++- mods/ENTITIES/mobs_mc/villager_zombie.lua | 1 + mods/ENTITIES/mobs_mc/wolf.lua | 1 + 12 files changed, 23 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/bat.lua b/mods/ENTITIES/mobs_mc/bat.lua index b41dabcba..1a40203c0 100644 --- a/mods/ENTITIES/mobs_mc/bat.lua +++ b/mods/ENTITIES/mobs_mc/bat.lua @@ -7,6 +7,7 @@ mcl_mobs:register_mob("mobs_mc:bat", { type = "animal", spawn_class = "ambient", can_despawn = true, + spawn_in_group = 8, passive = true, hp_min = 6, hp_max = 6, diff --git a/mods/ENTITIES/mobs_mc/blaze.lua b/mods/ENTITIES/mobs_mc/blaze.lua index e0ff50909..c06e0bea6 100644 --- a/mods/ENTITIES/mobs_mc/blaze.lua +++ b/mods/ENTITIES/mobs_mc/blaze.lua @@ -16,6 +16,8 @@ mcl_mobs:register_mob("mobs_mc:blaze", { description = S("Blaze"), type = "monster", spawn_class = "hostile", + spawn_in_group_min = 2, + spawn_in_group = 3, hp_min = 20, hp_max = 20, xp_min = 10, diff --git a/mods/ENTITIES/mobs_mc/cod.lua b/mods/ENTITIES/mobs_mc/cod.lua index 9174cd65f..fe72c2f84 100644 --- a/mods/ENTITIES/mobs_mc/cod.lua +++ b/mods/ENTITIES/mobs_mc/cod.lua @@ -40,7 +40,8 @@ local cod = { xp_max = 3, armor = 100, rotate = 180, - spawn_in_group = 10, + spawn_in_group_min = 3, + spawn_in_group = 8, 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/cow+mooshroom.lua b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua index b2d6158bc..256c3d8aa 100644 --- a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua +++ b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua @@ -83,6 +83,8 @@ mcl_mobs:register_mob("mobs_mc:cow", cow_def) local mooshroom_def = table.copy(cow_def) mooshroom_def.description = S("Mooshroom") mooshroom_def.mesh = "mobs_mc_cow.b3d" +mooshroom_def.spawn_in_group_min = 4 +mooshroom_def.spawn_in_group = 8 mooshroom_def.textures = { {"mobs_mc_mooshroom.png", "mobs_mc_mushroom_red.png"}, {"mobs_mc_mooshroom_brown.png", "mobs_mc_mushroom_brown.png" } } mooshroom_def.on_rightclick = function(self, clicker) if mcl_mobs:feed_tame(self, clicker, 1, true, true) then return end diff --git a/mods/ENTITIES/mobs_mc/ghast.lua b/mods/ENTITIES/mobs_mc/ghast.lua index d08b0055c..c5172c4e5 100644 --- a/mods/ENTITIES/mobs_mc/ghast.lua +++ b/mods/ENTITIES/mobs_mc/ghast.lua @@ -23,6 +23,7 @@ mcl_mobs:register_mob("mobs_mc:ghast", { collisionbox = {-2, 5, -2, 2, 9, 2}, visual = "mesh", mesh = "mobs_mc_ghast.b3d", + spawn_in_group = 1, textures = { {"mobs_mc_ghast.png"}, }, diff --git a/mods/ENTITIES/mobs_mc/guardian.lua b/mods/ENTITIES/mobs_mc/guardian.lua index 53e93f472..dd5f3a83e 100644 --- a/mods/ENTITIES/mobs_mc/guardian.lua +++ b/mods/ENTITIES/mobs_mc/guardian.lua @@ -8,12 +8,14 @@ mcl_mobs:register_mob("mobs_mc:guardian", { description = S("Guardian"), type = "monster", spawn_class = "hostile", + spawn_in_group_min = 2, + spawn_in_group = 4, hp_min = 30, hp_max = 30, xp_min = 10, xp_max = 10, breath_max = -1, - passive = false, + passive = false, attack_type = "dogfight", pathfinding = 1, view_range = 16, diff --git a/mods/ENTITIES/mobs_mc/horse.lua b/mods/ENTITIES/mobs_mc/horse.lua index 20ff8b718..ffa2548d0 100644 --- a/mods/ENTITIES/mobs_mc/horse.lua +++ b/mods/ENTITIES/mobs_mc/horse.lua @@ -100,6 +100,8 @@ local horse = { description = S("Horse"), type = "animal", spawn_class = "passive", + spawn_in_group_min = 2, + spawn_in_group = 6, visual = "mesh", mesh = "mobs_mc_horse.b3d", visual_size = {x=3.0, y=3.0}, @@ -490,6 +492,8 @@ local d = 0.86 -- donkey scale local donkey = table.copy(horse) donkey.description = S("Donkey") donkey.textures = {{"blank.png", "mobs_mc_donkey.png", "blank.png"}} +donkey.spawn_in_group = 3 +donkey.spawn_in_group_min = 1 donkey.animation = { speed_normal = 25, stand_start = 0, stand_end = 0, diff --git a/mods/ENTITIES/mobs_mc/llama.lua b/mods/ENTITIES/mobs_mc/llama.lua index a211b117a..94ab7a094 100644 --- a/mods/ENTITIES/mobs_mc/llama.lua +++ b/mods/ENTITIES/mobs_mc/llama.lua @@ -28,6 +28,8 @@ mcl_mobs:register_mob("mobs_mc:llama", { description = S("Llama"), type = "animal", spawn_class = "passive", + spawn_in_group_min = 4, + spawn_in_group = 6, hp_min = 15, hp_max = 30, xp_min = 1, diff --git a/mods/ENTITIES/mobs_mc/ocelot.lua b/mods/ENTITIES/mobs_mc/ocelot.lua index 983199762..7d8b444da 100644 --- a/mods/ENTITIES/mobs_mc/ocelot.lua +++ b/mods/ENTITIES/mobs_mc/ocelot.lua @@ -30,6 +30,8 @@ local ocelot = { type = "animal", spawn_class = "passive", can_despawn = true, + spawn_in_group = 3, + spawn_in_group_min = 1, hp_min = 10, hp_max = 10, xp_min = 1, diff --git a/mods/ENTITIES/mobs_mc/rabbit.lua b/mods/ENTITIES/mobs_mc/rabbit.lua index 2632eafce..c11167007 100644 --- a/mods/ENTITIES/mobs_mc/rabbit.lua +++ b/mods/ENTITIES/mobs_mc/rabbit.lua @@ -6,9 +6,10 @@ local rabbit = { description = S("Rabbit"), type = "animal", spawn_class = "passive", + spawn_in_group_min = 2, + spawn_in_group = 3, passive = true, reach = 1, - hp_min = 3, hp_max = 3, xp_min = 1, diff --git a/mods/ENTITIES/mobs_mc/villager_zombie.lua b/mods/ENTITIES/mobs_mc/villager_zombie.lua index daeed9e9a..fedbf5a6e 100644 --- a/mods/ENTITIES/mobs_mc/villager_zombie.lua +++ b/mods/ENTITIES/mobs_mc/villager_zombie.lua @@ -29,6 +29,7 @@ mcl_mobs:register_mob("mobs_mc:villager_zombie", { description = S("Zombie Villager"), type = "monster", spawn_class = "hostile", + spawn_in_group = 1, hp_min = 20, hp_max = 20, xp_min = 5, diff --git a/mods/ENTITIES/mobs_mc/wolf.lua b/mods/ENTITIES/mobs_mc/wolf.lua index d875bebf9..a1606836d 100644 --- a/mods/ENTITIES/mobs_mc/wolf.lua +++ b/mods/ENTITIES/mobs_mc/wolf.lua @@ -18,6 +18,7 @@ local wolf = { xp_max = 3, passive = false, group_attack = true, + spawn_in_group = 8, collisionbox = {-0.3, -0.01, -0.3, 0.3, 0.84, 0.3}, visual = "mesh", mesh = "mobs_mc_wolf.b3d", From 3a32e4e4e9716c9b9b3b4dc6b4d6b3e86fa2802e Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 17 Jul 2022 02:30:16 +0200 Subject: [PATCH 04/10] Never spawn mobs on bedrock --- mods/ENTITIES/mcl_mobs/spawning.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/spawning.lua index b3de6f50f..d97d99536 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -432,6 +432,7 @@ if mobs_spawn then local is_water = get_item_group(gotten_node, "water") ~= 0 local is_lava = get_item_group(gotten_node, "lava") ~= 0 local is_leaf = get_item_group(gotten_node, "leaves") ~= 0 + local is_bedrock = gotten_node == "mcl_core:bedrock" local is_ground = not (is_water or is_lava) local is_grass = minetest.get_item_group(gotten_node,"grass_block") ~= 0 local has_bed = minetest.find_node_near(pos,25,{"group:bed"}) @@ -478,6 +479,7 @@ if mobs_spawn then and (not is_farm_animal(mob_def.name) or is_grass) and (mob_type ~= "npc" or has_bed) and (mob_def.type_of_spawning ~= "water" or is_water) + and not is_bedrock then if mob_def.type_of_spawning == "water" then spawning_position = get_water_spawn(spawning_position) From 987ae3c6e88474f9a22c25119d1747331013a15c Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 17 Jul 2022 02:34:34 +0200 Subject: [PATCH 05/10] Fix mobs spawning inside nodes --- mods/ENTITIES/mcl_mobs/api.lua | 1 + mods/ENTITIES/mcl_mobs/spawning.lua | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 61bed6901..d77a9c419 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -4036,6 +4036,7 @@ minetest.register_entity(name, { 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, + spawn_in_group_min = def.spawn_in_group_min, -- 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 d97d99536..943d751f2 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -388,7 +388,12 @@ end local function spawn_group(p,mob,spawn_on,group_max,group_min) if not group_min then group_min = 1 end - local nn = minetest.find_nodes_in_area(vector.offset(p,-5,-3,-5),vector.offset(p,5,3,5),spawn_on) + local nn + if mob.spawn_class == "water" then + nn= minetest.find_nodes_in_area(vector.offset(p,-5,-3,-5),vector.offset(p,5,3,5),spawn_on) + else + nn= minetest.find_nodes_in_area_under_air(vector.offset(p,-5,-3,-5),vector.offset(p,5,3,5),spawn_on) + end local o if not nn or #nn < 1 then nn = {} From 2d3f4531c94cfd21a2af5539601e30483c90c128 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 17 Jul 2022 03:45:41 +0200 Subject: [PATCH 06/10] Add mob spawning debug command --- mods/ENTITIES/mcl_mobs/spawning.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/spawning.lua index 943d751f2..6d17be0ad 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -205,6 +205,16 @@ local function count_mobs(pos) return num end +local function count_mobs_total() + local num = 0 + for _,l in pairs(minetest.luaentities) do + if l.is_mob then + num = num + 1 + end + end + return num +end + -- global functions @@ -386,6 +396,9 @@ local function get_water_spawn(p) end end +local dbg_spawn_attempts = 0 +local dbg_spawn_succ = 0 + local function spawn_group(p,mob,spawn_on,group_max,group_min) if not group_min then group_min = 1 end local nn @@ -401,15 +414,28 @@ local function spawn_group(p,mob,spawn_on,group_max,group_min) end for i = 1, math.random(group_min,group_max) do o = minetest.add_entity(nn[math.random(#nn)],mob) + if o then dbg_spawn_succ = dbg_spawn_succ + 1 end end return o end +minetest.register_chatcommand("mobstats",{ + privs = { debug = true }, + func = function(n,param) + local pos = minetest.get_player_by_name(n):get_pos() + minetest.chat_send_player(n,"mobs within 32 radius of player:"..count_mobs(pos)) + minetest.chat_send_player(n,"total mobs:"..count_mobs_total()) + minetest.chat_send_player(n,"spawning attempts since server start:"..dbg_spawn_attempts) + minetest.chat_send_player(n,"successful spawns since server start:"..dbg_spawn_succ) + end +}) + if mobs_spawn then local perlin_noise local function spawn_a_mob(pos, dimension, y_min, y_max) + dbg_spawn_attempts = dbg_spawn_attempts + 1 local dimension = dimension or mcl_worlds.pos_to_dimension(pos) local goal_pos = get_next_mob_spawn_pos(pos) local spawning_position_list = find_nodes_in_area_under_air( From 1087d9e54b295dc26fcf008b8c6792036e7f0f36 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 17 Jul 2022 05:42:45 +0200 Subject: [PATCH 07/10] Implement mc like mob cap --- mods/ENTITIES/mcl_mobs/spawning.lua | 62 ++++++++++++++++++----------- mods/ENTITIES/mobs_mc/dolphin.lua | 2 +- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/spawning.lua index 6d17be0ad..4fdcf251a 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -15,7 +15,7 @@ local math_cos = math.cos local math_sin = math.sin local math_round = function(x) return (x > 0) and math_floor(x + 0.5) or math_ceil(x - 0.5) end ---local vector_distance = vector.distance +local vector_distance = vector.distance local vector_new = vector.new local vector_floor = vector.floor @@ -25,7 +25,15 @@ local table_remove = table.remove local pairs = pairs -- range for mob count -local aoc_range = 32 +local aoc_range = 136 + +local mob_cap = { + monster = 70, + animal =10, + ambient =15, + water = 5, --currently unused + water_ambient = 20, --currently unused +} --do mobs spawn? local mobs_spawn = minetest.settings:get_bool("mobs_spawn", true) ~= false @@ -153,6 +161,10 @@ local list_of_all_biomes = { -- dimension biome: "Nether", + "BasaltDelta", + "CrimsonForest", + "WarpedForest", + "SoulsandValley", "End", -- Overworld regular: @@ -189,27 +201,29 @@ local list_of_all_biomes = { "MesaBryce", "JungleEdge", "SavannaM", - "Nether", - "WarpedForest", - "SoulsandValley" } -- count how many mobs are in an area -local function count_mobs(pos) +local function count_mobs(pos,r,mob_type) local num = 0 - for _,object in pairs(get_objects_inside_radius(pos, aoc_range)) do - if object and object:get_luaentity() and object:get_luaentity().is_mob then - num = num + 1 + for _,l in pairs(minetest.luaentities) do + if l and l.is_mob and (mob_type == nil or l.type == mob_type) then + local p = l.object:get_pos() + if p and vector_distance(p,pos) < r then + num = num + 1 + end end end return num end -local function count_mobs_total() +local function count_mobs_total(mob_type) local num = 0 for _,l in pairs(minetest.luaentities) do if l.is_mob then - num = num + 1 + if mob_type == nil or l.type == mob_type then + num = num + 1 + end end end return num @@ -302,7 +316,7 @@ function mcl_mobs:spawn_setup(def) spawn_dictionary[#spawn_dictionary + 1] = { name = name, dimension = dimension, - type_of_spawning = type_of_spawning, + type_of_spawning = type_of_spawning, biomes = biomes, min_light = min_light, max_light = max_light, @@ -401,19 +415,18 @@ local dbg_spawn_succ = 0 local function spawn_group(p,mob,spawn_on,group_max,group_min) if not group_min then group_min = 1 end - local nn - if mob.spawn_class == "water" then - nn= minetest.find_nodes_in_area(vector.offset(p,-5,-3,-5),vector.offset(p,5,3,5),spawn_on) - else - nn= minetest.find_nodes_in_area_under_air(vector.offset(p,-5,-3,-5),vector.offset(p,5,3,5),spawn_on) - end + local nn= minetest.find_nodes_in_area_under_air(vector.offset(p,-5,-3,-5),vector.offset(p,5,3,5),spawn_on) local o if not nn or #nn < 1 then nn = {} table.insert(nn,p) end for i = 1, math.random(group_min,group_max) do - o = minetest.add_entity(nn[math.random(#nn)],mob) + local sp = vector.offset(nn[math.random(#nn)],0,1,0) + if mob.type_of_spawning == "water" then + sp = get_water_spawn(sp) + end + o = minetest.add_entity(sp,mob.name) if o then dbg_spawn_succ = dbg_spawn_succ + 1 end end return o @@ -423,7 +436,7 @@ minetest.register_chatcommand("mobstats",{ privs = { debug = true }, func = function(n,param) local pos = minetest.get_player_by_name(n):get_pos() - minetest.chat_send_player(n,"mobs within 32 radius of player:"..count_mobs(pos)) + minetest.chat_send_player(n,"mobs within 32 radius of player:"..count_mobs(pos,32)) minetest.chat_send_player(n,"total mobs:"..count_mobs_total()) minetest.chat_send_player(n,"spawning attempts since server start:"..dbg_spawn_attempts) minetest.chat_send_player(n,"successful spawns since server start:"..dbg_spawn_succ) @@ -446,9 +459,6 @@ if mobs_spawn then if #spawning_position_list <= 0 then return end local spawning_position = spawning_position_list[math_random(1, #spawning_position_list)] - --hard code mob limit in area to 5 for now - if count_mobs(spawning_position) >= 5 then return end - local gotten_node = get_node(spawning_position).name local gotten_biome = minetest.get_biome_data(spawning_position) if not gotten_node or not gotten_biome then return end @@ -497,7 +507,11 @@ if mobs_spawn then 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 or 4 + local mob_count_wide = count_mobs(pos,aoc_range,mob_type) + local mob_count = count_mobs(spawning_position,32,mob_type) if mob_def + and mob_count_wide < (mob_cap[mob_type] or 15) + and mob_count < 5 and spawning_position.y >= mob_def.min_height and spawning_position.y <= mob_def.max_height and mob_def.dimension == dimension @@ -521,7 +535,7 @@ if mobs_spawn then --everything is correct, spawn mob local object if spawn_in_group then - object = spawn_group(spawning_position,mob_def.name,{gotten_node},spawn_in_group,spawn_in_group_min) + object = spawn_group(spawning_position,mob_def,{gotten_node},spawn_in_group,spawn_in_group_min) else object = minetest.add_entity(spawning_position, mob_def.name) end diff --git a/mods/ENTITIES/mobs_mc/dolphin.lua b/mods/ENTITIES/mobs_mc/dolphin.lua index 01e6f56ee..095657470 100644 --- a/mods/ENTITIES/mobs_mc/dolphin.lua +++ b/mods/ENTITIES/mobs_mc/dolphin.lua @@ -30,7 +30,7 @@ local S = minetest.get_translator(minetest.get_current_modname()) --################### local dolphin = { - type = "monster", + type = "animal", spawn_class = "water", can_despawn = true, passive = true, From 99037cb0ecd467bcfc2a92ae5161f924e6bcf02c Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 17 Jul 2022 15:33:06 +0200 Subject: [PATCH 08/10] adapt several mob spawning conditions to mc --- mods/ENTITIES/mcl_mobs/spawning.lua | 3 ++- mods/ENTITIES/mobs_mc/chicken.lua | 2 -- mods/ENTITIES/mobs_mc/common.lua | 0 mods/ENTITIES/mobs_mc/cow+mooshroom.lua | 5 ----- mods/ENTITIES/mobs_mc/creeper.lua | 5 ----- mods/ENTITIES/mobs_mc/dolphin.lua | 4 ++-- mods/ENTITIES/mobs_mc/enderman.lua | 6 +++--- mods/ENTITIES/mobs_mc/horse.lua | 2 +- mods/ENTITIES/mobs_mc/llama.lua | 18 ++++++++---------- mods/ENTITIES/mobs_mc/pig.lua | 5 ----- mods/ENTITIES/mobs_mc/sheep.lua | 2 +- mods/ENTITIES/mobs_mc/skeleton_wither.lua | 3 ++- mods/ENTITIES/mobs_mc/slime+magma_cube.lua | 5 ----- mods/ENTITIES/mobs_mc/spider.lua | 5 ----- mods/ENTITIES/mobs_mc/zombie.lua | 6 ------ mods/ENTITIES/mobs_mc/zombiepig.lua | 3 ++- 16 files changed, 21 insertions(+), 53 deletions(-) delete mode 100644 mods/ENTITIES/mobs_mc/common.lua diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/spawning.lua index 4fdcf251a..4e45a0045 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -174,6 +174,8 @@ local list_of_all_biomes = { "Swampland", "Taiga", "ExtremeHills", + "ExtremeHillsM", + "ExtremeHills+_snowtop", "Jungle", "Savanna", "BirchForest", @@ -192,7 +194,6 @@ local list_of_all_biomes = { "ExtremeHills+_snowtop", "MesaPlateauFM_grasstop", "JungleEdgeM", - "ExtremeHillsM", "JungleM", "BirchForestM", "MesaPlateauF", diff --git a/mods/ENTITIES/mobs_mc/chicken.lua b/mods/ENTITIES/mobs_mc/chicken.lua index a36b58502..886a945b9 100644 --- a/mods/ENTITIES/mobs_mc/chicken.lua +++ b/mods/ENTITIES/mobs_mc/chicken.lua @@ -122,8 +122,6 @@ mcl_mobs:spawn_specific( "ExtremeHills_beach", "ExtremeHillsM", "ExtremeHills+", - "ExtremeHills+_snowtop", - "StoneBeach", "Plains", "Plains_beach", "SunflowerPlains", diff --git a/mods/ENTITIES/mobs_mc/common.lua b/mods/ENTITIES/mobs_mc/common.lua deleted file mode 100644 index e69de29bb..000000000 diff --git a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua index 256c3d8aa..d72a6c0f9 100644 --- a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua +++ b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua @@ -153,17 +153,12 @@ mcl_mobs:spawn_specific( "ground", { "flat", - "IcePlainsSpikes", - "ColdTaiga", - "ColdTaiga_beach", - "ColdTaiga_beach_water", "MegaTaiga", "MegaSpruceTaiga", "ExtremeHills", "ExtremeHills_beach", "ExtremeHillsM", "ExtremeHills+", - "ExtremeHills+_snowtop", "StoneBeach", "Plains", "Plains_beach", diff --git a/mods/ENTITIES/mobs_mc/creeper.lua b/mods/ENTITIES/mobs_mc/creeper.lua index 8d50c6755..c98abe718 100644 --- a/mods/ENTITIES/mobs_mc/creeper.lua +++ b/mods/ENTITIES/mobs_mc/creeper.lua @@ -274,7 +274,6 @@ mcl_mobs:spawn_specific( "Plains", "Desert", "ColdTaiga", -"MushroomIsland", "IcePlainsSpikes", "SunflowerPlains", "IcePlains", @@ -301,7 +300,6 @@ mcl_mobs:spawn_specific( "ExtremeHills_beach", "ColdTaiga_beach", "Swampland_shore", -"MushroomIslandShore", "JungleM_shore", "Jungle_shore", "MesaPlateauFM_sandlevel", @@ -340,7 +338,6 @@ mcl_mobs:spawn_specific( "Forest_deep_ocean", "JungleM_deep_ocean", "FlowerForest_deep_ocean", -"MushroomIsland_ocean", "MegaTaiga_ocean", "StoneBeach_deep_ocean", "IcePlainsSpikes_deep_ocean", @@ -350,7 +347,6 @@ mcl_mobs:spawn_specific( "MesaBryce_deep_ocean", "ExtremeHills+_deep_ocean", "ExtremeHills_ocean", -"MushroomIsland_deep_ocean", "Forest_ocean", "MegaTaiga_deep_ocean", "JungleEdge_ocean", @@ -376,7 +372,6 @@ mcl_mobs:spawn_specific( "RoofedForest_underground", "Jungle_underground", "Swampland_underground", -"MushroomIsland_underground", "BirchForest_underground", "Plains_underground", "MesaPlateauF_underground", diff --git a/mods/ENTITIES/mobs_mc/dolphin.lua b/mods/ENTITIES/mobs_mc/dolphin.lua index 095657470..2afe04c43 100644 --- a/mods/ENTITIES/mobs_mc/dolphin.lua +++ b/mods/ENTITIES/mobs_mc/dolphin.lua @@ -42,7 +42,8 @@ local dolphin = { walk_chance = 100, breath_max = 120, rotate = 180, - spawn_in_group = 3, + spawn_in_group_min = 3, + spawn_in_group = 5, tilt_swim = true, collisionbox = {-0.3, 0.0, -0.3, 0.3, 0.79, 0.3}, visual = "mesh", @@ -136,7 +137,6 @@ mcl_mobs:spawn_specific( "FlowerForest_beach", "Forest_beach", "StoneBeach", -"ColdTaiga_beach_water", "Taiga_beach", "Savanna_beach", "Plains_beach", diff --git a/mods/ENTITIES/mobs_mc/enderman.lua b/mods/ENTITIES/mobs_mc/enderman.lua index 4dcd6693c..e49a22957 100644 --- a/mods/ENTITIES/mobs_mc/enderman.lua +++ b/mods/ENTITIES/mobs_mc/enderman.lua @@ -767,10 +767,10 @@ mcl_mobs:spawn_specific( "ground", { "Nether", -"SoulsandValley", +"SoulsandVall3ey", }, 0, -minetest.LIGHT_MAX+1, +11, 30, 27500, 4, @@ -786,7 +786,7 @@ mcl_mobs:spawn_specific( "WarpedForest" }, 0, -minetest.LIGHT_MAX+1, +11, 30, 5000, 4, diff --git a/mods/ENTITIES/mobs_mc/horse.lua b/mods/ENTITIES/mobs_mc/horse.lua index ffa2548d0..30c8e7d94 100644 --- a/mods/ENTITIES/mobs_mc/horse.lua +++ b/mods/ENTITIES/mobs_mc/horse.lua @@ -578,7 +578,7 @@ mcl_mobs:spawn_specific( "Savanna_beach", "Plains_beach", }, -0, +9, minetest.LIGHT_MAX+1, 30, 15000, diff --git a/mods/ENTITIES/mobs_mc/llama.lua b/mods/ENTITIES/mobs_mc/llama.lua index 94ab7a094..e11566e3e 100644 --- a/mods/ENTITIES/mobs_mc/llama.lua +++ b/mods/ENTITIES/mobs_mc/llama.lua @@ -219,18 +219,16 @@ mcl_mobs:spawn_specific( "overworld", "ground", { - "Mesa", - "MesaPlateauFM_grasstop", - "MesaPlateauF", - "MesaPlateauFM", - "MesaPlateauF_grasstop", - "MesaBryce", - "Jungle", - "Jungle_shore", - "JungleM", - "JungleM_shore", + "Savanna", + "SavannaM", + "SavannaM_beach", + "Savanna_beach", + "Savanna_ocean", "JungleEdge", "JungleEdgeM", + "ExtremeHills", + "ExtremeHills_beach", + "ExtremeHillsM", }, 0, minetest.LIGHT_MAX+1, diff --git a/mods/ENTITIES/mobs_mc/pig.lua b/mods/ENTITIES/mobs_mc/pig.lua index 3cf88b915..b1958dc69 100644 --- a/mods/ENTITIES/mobs_mc/pig.lua +++ b/mods/ENTITIES/mobs_mc/pig.lua @@ -194,17 +194,12 @@ mcl_mobs:spawn_specific( "ground", { "flat", - "IcePlainsSpikes", - "ColdTaiga", - "ColdTaiga_beach", - "ColdTaiga_beach_water", "MegaTaiga", "MegaSpruceTaiga", "ExtremeHills", "ExtremeHills_beach", "ExtremeHillsM", "ExtremeHills+", - "ExtremeHills+_snowtop", "StoneBeach", "Plains", "Plains_beach", diff --git a/mods/ENTITIES/mobs_mc/sheep.lua b/mods/ENTITIES/mobs_mc/sheep.lua index d2d09be50..412c0cbdb 100644 --- a/mods/ENTITIES/mobs_mc/sheep.lua +++ b/mods/ENTITIES/mobs_mc/sheep.lua @@ -346,7 +346,7 @@ mcl_mobs:spawn_specific( "Swampland", "Swampland_shore" }, -0, +9, minetest.LIGHT_MAX+1, 30, 15000, diff --git a/mods/ENTITIES/mobs_mc/skeleton_wither.lua b/mods/ENTITIES/mobs_mc/skeleton_wither.lua index 5e31453fa..040f22d66 100644 --- a/mods/ENTITIES/mobs_mc/skeleton_wither.lua +++ b/mods/ENTITIES/mobs_mc/skeleton_wither.lua @@ -101,7 +101,8 @@ mcl_mobs:spawn_specific( "nether", "ground", { -"Nether" +"Nether", +"SoulsandValley", }, 0, 7, diff --git a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua index 911ae15e8..701ae852a 100644 --- a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua +++ b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua @@ -446,11 +446,6 @@ minetest.LIGHT_MAX+1, mmin, mmax) ---mcl_mobs:spawn_specific("mobs_mc:magma_cube_tiny", { "mcl_nether:nether_brick", "mcl_nether:netherrack" }, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 11000, 4, mmin, mmax) ---mcl_mobs:spawn_specific("mobs_mc:magma_cube_small", { "mcl_nether:nether_brick", "mcl_nether:netherrack" }, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 11100, 4, mmin, mmax) ---mcl_mobs:spawn_specific("mobs_mc:magma_cube_big", { "mcl_nether:nether_brick", "mcl_nether:netherrack" }, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 11200, 4, mmin, mmax) - - -- spawn eggs mcl_mobs:register_egg("mobs_mc:magma_cube_big", S("Magma Cube"), "mobs_mc_spawn_icon_magmacube.png") mcl_mobs:register_egg("mobs_mc:slime_big", S("Slime"), "mobs_mc_spawn_icon_slime.png") diff --git a/mods/ENTITIES/mobs_mc/spider.lua b/mods/ENTITIES/mobs_mc/spider.lua index 0fc16928e..b39db1ea1 100644 --- a/mods/ENTITIES/mobs_mc/spider.lua +++ b/mods/ENTITIES/mobs_mc/spider.lua @@ -109,7 +109,6 @@ mcl_mobs:spawn_specific( "Plains", "Desert", "ColdTaiga", -"MushroomIsland", "IcePlainsSpikes", "SunflowerPlains", "IcePlains", @@ -136,7 +135,6 @@ mcl_mobs:spawn_specific( "ExtremeHills_beach", "ColdTaiga_beach", "Swampland_shore", -"MushroomIslandShore", "JungleM_shore", "Jungle_shore", "MesaPlateauFM_sandlevel", @@ -175,7 +173,6 @@ mcl_mobs:spawn_specific( "Forest_deep_ocean", "JungleM_deep_ocean", "FlowerForest_deep_ocean", -"MushroomIsland_ocean", "MegaTaiga_ocean", "StoneBeach_deep_ocean", "IcePlainsSpikes_deep_ocean", @@ -185,7 +182,6 @@ mcl_mobs:spawn_specific( "MesaBryce_deep_ocean", "ExtremeHills+_deep_ocean", "ExtremeHills_ocean", -"MushroomIsland_deep_ocean", "Forest_ocean", "MegaTaiga_deep_ocean", "JungleEdge_ocean", @@ -211,7 +207,6 @@ mcl_mobs:spawn_specific( "RoofedForest_underground", "Jungle_underground", "Swampland_underground", -"MushroomIsland_underground", "BirchForest_underground", "Plains_underground", "MesaPlateauF_underground", diff --git a/mods/ENTITIES/mobs_mc/zombie.lua b/mods/ENTITIES/mobs_mc/zombie.lua index 640b2ed11..c27d9b8f4 100644 --- a/mods/ENTITIES/mobs_mc/zombie.lua +++ b/mods/ENTITIES/mobs_mc/zombie.lua @@ -162,7 +162,6 @@ mcl_mobs:spawn_specific( "RoofedForest_underground", "Jungle_underground", "Swampland_underground", -"MushroomIsland_underground", "BirchForest_underground", "Plains_underground", "MesaPlateauF_underground", @@ -198,7 +197,6 @@ mcl_mobs:spawn_specific( "Forest", "Plains", "ColdTaiga", -"MushroomIsland", "IcePlainsSpikes", "SunflowerPlains", "IcePlains", @@ -225,7 +223,6 @@ mcl_mobs:spawn_specific( "ExtremeHills_beach", "ColdTaiga_beach", "Swampland_shore", -"MushroomIslandShore", "JungleM_shore", "Jungle_shore", "MesaPlateauFM_sandlevel", @@ -254,7 +251,6 @@ mcl_mobs:spawn_specific( "RoofedForest_underground", "Jungle_underground", "Swampland_underground", -"MushroomIsland_underground", "BirchForest_underground", "Plains_underground", "MesaPlateauF_underground", @@ -290,7 +286,6 @@ mcl_mobs:spawn_specific( "Forest", "Plains", "ColdTaiga", -"MushroomIsland", "IcePlainsSpikes", "SunflowerPlains", "IcePlains", @@ -317,7 +312,6 @@ mcl_mobs:spawn_specific( "ExtremeHills_beach", "ColdTaiga_beach", "Swampland_shore", -"MushroomIslandShore", "JungleM_shore", "Jungle_shore", "MesaPlateauFM_sandlevel", diff --git a/mods/ENTITIES/mobs_mc/zombiepig.lua b/mods/ENTITIES/mobs_mc/zombiepig.lua index b054734bc..33838a9b5 100644 --- a/mods/ENTITIES/mobs_mc/zombiepig.lua +++ b/mods/ENTITIES/mobs_mc/zombiepig.lua @@ -134,7 +134,8 @@ mcl_mobs:spawn_specific( "nether", "ground", { -"Nether" +"Nether", +"CrimsonForest", }, 0, minetest.LIGHT_MAX+1, From bf756403a379fc140cc55401f13e721d1b80eeee Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 17 Jul 2022 16:16:53 +0200 Subject: [PATCH 09/10] Fix animals attacking players for no reason --- mods/ENTITIES/mcl_mobs/api.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index d77a9c419..c7b55b32a 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -1926,10 +1926,9 @@ local monster_attack = function(self) for n = 1, #objs do if objs[n]:is_player() then - if mcl_mobs.invis[ objs[n]:get_player_name() ] or (not object_in_range(self, objs[n])) then type = "" - else + elseif (self.type == "monster" or self._aggro) then player = objs[n] type = "player" name = "player" @@ -3345,11 +3344,11 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir) and (self.child == false or self.type == "monster") and hitter:get_player_name() ~= self.owner and not mcl_mobs.invis[ name ] then - if not die then -- attack whoever punched mob self.state = "" do_attack(self, hitter) + self._aggro= true end -- alert others to the attack @@ -3361,7 +3360,6 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir) obj = objs[n]:get_luaentity() if obj then - -- only alert members of same mob or friends if obj.group_attack and obj.state ~= "attack" @@ -3371,6 +3369,7 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir) elseif type(obj.group_attack) == "table" then for i=1, #obj.group_attack do if obj.name == obj.group_attack[i] then + obj._aggro = true do_attack(obj, hitter) break end From 68d45ff606a98bef57123d87257901825d9689fb Mon Sep 17 00:00:00 2001 From: cora Date: Mon, 18 Jul 2022 02:09:28 +0200 Subject: [PATCH 10/10] Remove MushroomIsland from several mobs spawn list --- mods/ENTITIES/mobs_mc/enderman.lua | 5 ----- mods/ENTITIES/mobs_mc/skeleton+stray.lua | 5 ----- mods/ENTITIES/mobs_mc/villager_zombie.lua | 3 --- 3 files changed, 13 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/enderman.lua b/mods/ENTITIES/mobs_mc/enderman.lua index e49a22957..8472f76e0 100644 --- a/mods/ENTITIES/mobs_mc/enderman.lua +++ b/mods/ENTITIES/mobs_mc/enderman.lua @@ -627,7 +627,6 @@ mcl_mobs:spawn_specific( "Plains", "Desert", "ColdTaiga", -"MushroomIsland", "IcePlainsSpikes", "SunflowerPlains", "IcePlains", @@ -654,7 +653,6 @@ mcl_mobs:spawn_specific( "ExtremeHills_beach", "ColdTaiga_beach", "Swampland_shore", -"MushroomIslandShore", "JungleM_shore", "Jungle_shore", "MesaPlateauFM_sandlevel", @@ -693,7 +691,6 @@ mcl_mobs:spawn_specific( "Forest_deep_ocean", "JungleM_deep_ocean", "FlowerForest_deep_ocean", -"MushroomIsland_ocean", "MegaTaiga_ocean", "StoneBeach_deep_ocean", "IcePlainsSpikes_deep_ocean", @@ -703,7 +700,6 @@ mcl_mobs:spawn_specific( "MesaBryce_deep_ocean", "ExtremeHills+_deep_ocean", "ExtremeHills_ocean", -"MushroomIsland_deep_ocean", "Forest_ocean", "MegaTaiga_deep_ocean", "JungleEdge_ocean", @@ -729,7 +725,6 @@ mcl_mobs:spawn_specific( "RoofedForest_underground", "Jungle_underground", "Swampland_underground", -"MushroomIsland_underground", "BirchForest_underground", "Plains_underground", "MesaPlateauF_underground", diff --git a/mods/ENTITIES/mobs_mc/skeleton+stray.lua b/mods/ENTITIES/mobs_mc/skeleton+stray.lua index 005bed66d..fbf16961a 100644 --- a/mods/ENTITIES/mobs_mc/skeleton+stray.lua +++ b/mods/ENTITIES/mobs_mc/skeleton+stray.lua @@ -162,7 +162,6 @@ mcl_mobs:spawn_specific( "Plains", "Desert", "ColdTaiga", -"MushroomIsland", "IcePlainsSpikes", "SunflowerPlains", "IcePlains", @@ -189,7 +188,6 @@ mcl_mobs:spawn_specific( "ExtremeHills_beach", "ColdTaiga_beach", "Swampland_shore", -"MushroomIslandShore", "JungleM_shore", "Jungle_shore", "MesaPlateauFM_sandlevel", @@ -228,7 +226,6 @@ mcl_mobs:spawn_specific( "Forest_deep_ocean", "JungleM_deep_ocean", "FlowerForest_deep_ocean", -"MushroomIsland_ocean", "MegaTaiga_ocean", "StoneBeach_deep_ocean", "IcePlainsSpikes_deep_ocean", @@ -238,7 +235,6 @@ mcl_mobs:spawn_specific( "MesaBryce_deep_ocean", "ExtremeHills+_deep_ocean", "ExtremeHills_ocean", -"MushroomIsland_deep_ocean", "Forest_ocean", "MegaTaiga_deep_ocean", "JungleEdge_ocean", @@ -264,7 +260,6 @@ mcl_mobs:spawn_specific( "RoofedForest_underground", "Jungle_underground", "Swampland_underground", -"MushroomIsland_underground", "BirchForest_underground", "Plains_underground", "MesaPlateauF_underground", diff --git a/mods/ENTITIES/mobs_mc/villager_zombie.lua b/mods/ENTITIES/mobs_mc/villager_zombie.lua index fedbf5a6e..cd0e89215 100644 --- a/mods/ENTITIES/mobs_mc/villager_zombie.lua +++ b/mods/ENTITIES/mobs_mc/villager_zombie.lua @@ -148,7 +148,6 @@ mcl_mobs:spawn_specific( "RoofedForest_underground", "Jungle_underground", "Swampland_underground", -"MushroomIsland_underground", "BirchForest_underground", "Plains_underground", "MesaPlateauF_underground", @@ -185,7 +184,6 @@ mcl_mobs:spawn_specific( "Plains", "Desert", "ColdTaiga", -"MushroomIsland", "IcePlainsSpikes", "SunflowerPlains", "IcePlains", @@ -212,7 +210,6 @@ mcl_mobs:spawn_specific( "ExtremeHills_beach", "ColdTaiga_beach", "Swampland_shore", -"MushroomIslandShore", "JungleM_shore", "Jungle_shore", "MesaPlateauFM_sandlevel",