From 94f0d679f2f24a2f348ef4bc04bda992551801c8 Mon Sep 17 00:00:00 2001 From: cora Date: Thu, 21 Jul 2022 01:02:24 +0200 Subject: [PATCH] Add can_spawn callback in mob api --- mods/ENTITIES/mcl_mobs/api.lua | 1 + mods/ENTITIES/mcl_mobs/spawning.lua | 3 +++ 2 files changed, 4 insertions(+) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index d86c04e80..8945c6e20 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -4034,6 +4034,7 @@ minetest.register_entity(name, { teleport = teleport, do_teleport = def.do_teleport, spawn_class = def.spawn_class, + can_spawn = def.can_spawn, ignores_nametag = def.ignores_nametag or false, rain_damage = def.rain_damage or 0, glow = def.glow, diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/spawning.lua index 4e45a0045..bc1b73716 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -533,6 +533,9 @@ if mobs_spawn then return end end + if minetest.registered_entities[mob_def.name].can_spawn and not minetest.registered_entities[mob_def.name].can_spawn(pos) then + return + end --everything is correct, spawn mob local object if spawn_in_group then