Merge pull request 'some mob spawning fixes (#1692)' (#2392) from ground_squids into master

Reviewed-on: MineClone2/MineClone2#2392
Reviewed-by: MysticTempest <mystictempest@noreply.git.minetest.land>
This commit is contained in:
cora 2022-07-04 21:02:39 +00:00
commit 0d8e6b103e
4 changed files with 13 additions and 11 deletions

View File

@ -453,11 +453,12 @@ if mobs_spawn then
and (mob_def.check_position and mob_def.check_position(spawning_position) or true) and (mob_def.check_position and mob_def.check_position(spawning_position) or true)
and (not is_farm_animal(mob_def.name) or is_grass) and (not is_farm_animal(mob_def.name) or is_grass)
and (mob_type ~= "npc" or has_bed) and (mob_type ~= "npc" or has_bed)
and (mob_def.type_of_spawning ~= water or is_water)
then then
--everything is correct, spawn mob --everything is correct, spawn mob
local object = minetest.add_entity(spawning_position, mob_def.name) local object = minetest.add_entity(spawning_position, mob_def.name)
if object then if object then
return mob_def.on_spawn and mob_def.on_spawn(object, pos) return mob_def.on_spawn and mob_def.on_spawn(object, spawning_position)
end end
end end
current_summary_chance = current_summary_chance - mob_chance current_summary_chance = current_summary_chance - mob_chance

View File

@ -76,7 +76,6 @@ mcl_mobs:spawn_specific(
"ColdTaiga", "ColdTaiga",
"IcePlainsSpikes", "IcePlainsSpikes",
"IcePlains", "IcePlains",
"ExtremeHills+_snowtop",
}, },
0, 0,
minetest.LIGHT_MAX+1, minetest.LIGHT_MAX+1,

View File

@ -132,18 +132,9 @@ mcl_mobs:spawn_specific(
"Desert", "Desert",
"FlowerForest", "FlowerForest",
"Taiga", "Taiga",
"ExtremeHills",
"BirchForest",
"MegaSpruceTaiga", "MegaSpruceTaiga",
"MegaTaiga", "MegaTaiga",
"ExtremeHills+",
"Plains",
"ColdTaiga", "ColdTaiga",
"SunflowerPlains",
"RoofedForest",
"MesaPlateauFM_grasstop",
"ExtremeHillsM",
"BirchForestM",
}, },
9, 9,
minetest.LIGHT_MAX+1, minetest.LIGHT_MAX+1,

View File

@ -55,6 +55,17 @@ mcl_mobs:register_mob("mobs_mc:squid", {
view_range = 16, view_range = 16,
runaway = true, runaway = true,
fear_height = 4, fear_height = 4,
on_spawn = function(self)
--make sure squids always spawn in water (and at variable heights)
--can be removed once this is provided by the api
local p = self.object:get_pos()
local nn = minetest.find_nodes_in_area(vector.offset(p,-2,-1,-2),vector.offset(p,2,-15,2),{"group:water"})
if nn and #nn > 0 then
self.object:set_pos(nn[math.random(#nn)])
else
self.object:remove()
end
end,
}) })
-- TODO: Behaviour: squirt -- TODO: Behaviour: squirt