From 5d48975a0724d5564cd25004c3016c714f23ab88 Mon Sep 17 00:00:00 2001 From: kay27 Date: Thu, 8 Apr 2021 00:44:20 +0400 Subject: [PATCH] [mineclone5] Make work new mob spawn by Oil_boi with extra_mobs --- mods/ENTITIES/extra_mobs/cod.lua | 2 +- mods/ENTITIES/extra_mobs/dolphin.lua | 2 +- mods/ENTITIES/extra_mobs/fox.lua | 6 ++-- mods/ENTITIES/extra_mobs/glow_squid.lua | 2 +- mods/ENTITIES/extra_mobs/hoglin+zoglin.lua | 2 +- mods/ENTITIES/extra_mobs/piglin.lua | 4 +-- mods/ENTITIES/extra_mobs/salmon.lua | 2 +- mods/ENTITIES/extra_mobs/strider.lua | 2 +- mods/ENTITIES/mcl_mobs/api.lua | 33 ++++++++++++++++++---- 9 files changed, 39 insertions(+), 16 deletions(-) diff --git a/mods/ENTITIES/extra_mobs/cod.lua b/mods/ENTITIES/extra_mobs/cod.lua index 5d37d6352..1a77a0ab8 100644 --- a/mods/ENTITIES/extra_mobs/cod.lua +++ b/mods/ENTITIES/extra_mobs/cod.lua @@ -102,7 +102,7 @@ mobs:register_mob("extra_mobs:cod", cod) --spawning TODO: in schools local water = mobs_mc.spawn_height.water -mobs:spawn_specific("extra_mobs:cod", mobs_mc.spawn.water, {mobs_mc.items.water_source}, 0, minetest.LIGHT_MAX+1, 30, 4000, 3, water-16, water) +mobs:spawn_specific("extra_mobs:cod", "overworld", "water", 0, minetest.LIGHT_MAX+1, 30, 4000, 3, water-16, water) --spawn egg mobs:register_egg("extra_mobs:cod", S("Cod"), "extra_mobs_spawn_icon_cod.png", 0) diff --git a/mods/ENTITIES/extra_mobs/dolphin.lua b/mods/ENTITIES/extra_mobs/dolphin.lua index 473bdf832..7701041bb 100644 --- a/mods/ENTITIES/extra_mobs/dolphin.lua +++ b/mods/ENTITIES/extra_mobs/dolphin.lua @@ -91,7 +91,7 @@ mobs:register_mob("extra_mobs:dolphin", dolphin) --spawning TODO: in schools local water = mobs_mc.spawn_height.water -mobs:spawn_specific("extra_mobs:dolphin", mobs_mc.spawn.water, {mobs_mc.items.water_source}, 0, minetest.LIGHT_MAX+1, 30, 4000, 3, water-16, water) +mobs:spawn_specific("extra_mobs:dolphin", "overworld", "water", 0, minetest.LIGHT_MAX+1, 30, 4000, 3, water-16, water) --spawn egg mobs:register_egg("extra_mobs:dolphin", S("dolphin"), "extra_mobs_spawn_icon_dolphin.png", 0) diff --git a/mods/ENTITIES/extra_mobs/fox.lua b/mods/ENTITIES/extra_mobs/fox.lua index db189e223..eb1741490 100644 --- a/mods/ENTITIES/extra_mobs/fox.lua +++ b/mods/ENTITIES/extra_mobs/fox.lua @@ -123,10 +123,10 @@ local fox = { mobs:register_mob("extra_mobs:fox", fox) -- spawning -mobs:spawn_specific("extra_mobs:fox", {"mcl_core:dirt_with_grass"}, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 6000, 3, 0, 500) +mobs:spawn_specific("extra_mobs:fox", "overworld", "ground", 0, minetest.LIGHT_MAX+1, 30, 6000, 3, 0, 500) -mobs:spawn_specific("extra_mobs:fox", {"mcl_core:dirt_with_grass_snow"}, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 6000, 3, 0, 500) -mobs:spawn_specific("extra_mobs:artic_fox", {"mcl_core:snow"}, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 6000, 3, 0, 500) +mobs:spawn_specific("extra_mobs:fox", "overworld", "ground", 0, minetest.LIGHT_MAX+1, 30, 6000, 3, 0, 500) +mobs:spawn_specific("extra_mobs:artic_fox", "overworld", "mcl_core:snow", 0, minetest.LIGHT_MAX+1, 30, 6000, 3, 0, 500) -- spawn eggs mobs:register_egg("extra_mobs:fox", S("Fox"), "extra_mobs_spawn_icon_fox.png", 0) diff --git a/mods/ENTITIES/extra_mobs/glow_squid.lua b/mods/ENTITIES/extra_mobs/glow_squid.lua index d437fe08c..55f97675d 100644 --- a/mods/ENTITIES/extra_mobs/glow_squid.lua +++ b/mods/ENTITIES/extra_mobs/glow_squid.lua @@ -75,7 +75,7 @@ mobs:register_mob("extra_mobs:glow_squid",{ -- spawning local water = mobs_mc.spawn_height.water -mobs:spawn_specific("extra_mobs:glow_squid", mobs_mc.spawn.water, {mobs_mc.items.water_source}, 0, minetest.LIGHT_MAX+1, 30, 10000, 3, water-16, water) +mobs:spawn_specific("extra_mobs:glow_squid", "overworld", "water", 0, minetest.LIGHT_MAX+1, 30, 10000, 3, water-16, water) -- spawn egg mobs:register_egg("extra_mobs:glow_squid", S("Glow Squid"), "extra_mobs_spawn_icon_glow_squid.png", 0) diff --git a/mods/ENTITIES/extra_mobs/hoglin+zoglin.lua b/mods/ENTITIES/extra_mobs/hoglin+zoglin.lua index 81460c03f..08914cb85 100644 --- a/mods/ENTITIES/extra_mobs/hoglin+zoglin.lua +++ b/mods/ENTITIES/extra_mobs/hoglin+zoglin.lua @@ -115,7 +115,7 @@ baby_hoglin.child = 1 mobs:register_mob("extra_mobs:baby_hoglin", baby_hoglin)]] -- Regular spawning in the Nether -mobs:spawn_specific("extra_mobs:hoglin", {"mcl_nether:netherrack"}, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 6000, 3, mcl_vars.mg_nether_min, mcl_vars.mg_nether_max) +mobs:spawn_specific("extra_mobs:hoglin", "nether", "ground", {"air"}, 0, minetest.LIGHT_MAX+1, 30, 6000, 3, mcl_vars.mg_nether_min, mcl_vars.mg_nether_max) -- spawn eggs mobs:register_egg("extra_mobs:hoglin", S("Hoglin"), "extra_mobs_spawn_icon_hoglin.png", 0) diff --git a/mods/ENTITIES/extra_mobs/piglin.lua b/mods/ENTITIES/extra_mobs/piglin.lua index 23a7a53fe..5578ca905 100644 --- a/mods/ENTITIES/extra_mobs/piglin.lua +++ b/mods/ENTITIES/extra_mobs/piglin.lua @@ -264,8 +264,8 @@ mobs:register_mob("extra_mobs:piglin_brute", piglin_brute) -- Regular spawning in the Nether -mobs:spawn_specific("extra_mobs:piglin", {"mcl_nether:netherrack"}, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 6000, 3, mcl_vars.mg_nether_min, mcl_vars.mg_nether_max) -mobs:spawn_specific("extra_mobs:sword_piglin", {"mcl_nether:netherrack"}, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 6000, 3, mcl_vars.mg_nether_min, mcl_vars.mg_nether_max) +mobs:spawn_specific("extra_mobs:piglin", "nether", "ground", 0, minetest.LIGHT_MAX+1, 30, 6000, 3, mcl_vars.mg_nether_min, mcl_vars.mg_nether_max) +mobs:spawn_specific("extra_mobs:sword_piglin", "nether", "ground", 0, minetest.LIGHT_MAX+1, 30, 6000, 3, mcl_vars.mg_nether_min, mcl_vars.mg_nether_max) -- spawn eggs mobs:register_egg("extra_mobs:piglin", S("piglin"), "extra_mobs_spawn_icon_piglin.png", 0) mobs:register_egg("extra_mobs:piglin_brute", S("piglin Brute"), "extra_mobs_spawn_icon_piglin.png", 0) diff --git a/mods/ENTITIES/extra_mobs/salmon.lua b/mods/ENTITIES/extra_mobs/salmon.lua index 84dd8a214..35e554789 100644 --- a/mods/ENTITIES/extra_mobs/salmon.lua +++ b/mods/ENTITIES/extra_mobs/salmon.lua @@ -61,7 +61,7 @@ mobs:register_mob("extra_mobs:salmon", salmon) --spawning TODO: in schools local water = mobs_mc.spawn_height.water -mobs:spawn_specific("extra_mobs:salmon", mobs_mc.spawn.water, {mobs_mc.items.water_source}, 0, minetest.LIGHT_MAX+1, 30, 4000, 3, water-16, water) +mobs:spawn_specific("extra_mobs:salmon", "overworld", "water", 0, minetest.LIGHT_MAX+1, 30, 4000, 3, water-16, water) --spawn egg mobs:register_egg("extra_mobs:salmon", S("Salmon"), "extra_mobs_spawn_icon_salmon.png", 0) diff --git a/mods/ENTITIES/extra_mobs/strider.lua b/mods/ENTITIES/extra_mobs/strider.lua index 359be8cc4..17c994946 100644 --- a/mods/ENTITIES/extra_mobs/strider.lua +++ b/mods/ENTITIES/extra_mobs/strider.lua @@ -217,7 +217,7 @@ baby_strider.child = 1 mobs:register_mob("extra_mobs:baby_strider", baby_strider) -- Regular spawning in the Nether -mobs:spawn_specific("extra_mobs:strider", {"mcl_nether:nether_lava_source"}, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 6000, 3, mcl_vars.mg_nether_min, mcl_vars.mg_nether_max) +mobs:spawn_specific("extra_mobs:strider", "nether", "lava", 0, minetest.LIGHT_MAX+1, 30, 6000, 3, mcl_vars.mg_nether_min, mcl_vars.mg_nether_max) -- spawn eggs mobs:register_egg("extra_mobs:strider", S("Strider"), "extra_mobs_spawn_icon_strider.png", 0) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index d85633421..bf4880231 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -4277,13 +4277,14 @@ end --I'm not sure what this does but disabling it doesn't cause a crash -j4i +-- Just compatibility problem with outer mob mods currently, so adding a warning and temporarily enabling back -kay27 2021-04-08 -- MarkBu's spawn function ---[[ -function mobs:spawn(def) +function mobs:spawn(def) + minetest.log("warning", "[mcl_mobs] Deprecated function call: `mobs:spawn()`. Please use mobs:spawn_specific() instead!") local name = def.name local nodes = def.nodes or {"group:soil", "group:stone"} - local neighbors = def.neighbors or {"air"} +-- local neighbors = def.neighbors or {"air"} local min_light = def.min_light or 0 local max_light = def.max_light or 15 local interval = def.interval or 30 @@ -4294,10 +4295,16 @@ function mobs:spawn(def) local day_toggle = def.day_toggle local on_spawn = def.on_spawn - mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, interval, + --mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, interval, + -- chance, active_object_count, min_height, max_height, day_toggle, on_spawn) + mobs:spawn_specific(name, "overworld", nodes, min_light, max_light, interval, + chance, active_object_count, min_height, max_height, day_toggle, on_spawn) + mobs:spawn_specific(name, "end", nodes, min_light, max_light, interval, + chance, active_object_count, min_height, max_height, day_toggle, on_spawn) + mobs:spawn_specific(name, "nether", nodes, min_light, max_light, interval, chance, active_object_count, min_height, max_height, day_toggle, on_spawn) end -]]-- + local axis @@ -4409,6 +4416,22 @@ minetest.register_globalstep(function(dtime) end --elseif mob_def.type == "lava" then --implement later + else -- mob_def.type is specific node name or group name + local spawning_position_list = minetest.find_nodes_in_area_under_air(vector.new(goal_pos.x,min,goal_pos.z), vector.new(goal_pos.x,max,goal_pos.z), mob_def.type) + + if #spawning_position_list <= 0 then + goto continue + end + + local spawning_position = spawning_position_list[math.random(1,#spawning_position_list)] + + spawning_position.y = spawning_position.y + 1 + + local gotten_light = minetest.get_node_light(spawning_position) + + if gotten_light and gotten_light >= mob_def.min_light and gotten_light <= mob_def.max_light then + minetest.add_entity(spawning_position, mob_def.name) + end end --local spawn minetest.find_nodes_in_area_under_air(vector.new(pos.x,pos.y-find_node_height,pos.z), vector.new(pos.x,pos.y+find_node_height,pos.z), {"group:solid"})