From d871b18e8fd78b43add5b3cdb6e78da10abe0d22 Mon Sep 17 00:00:00 2001 From: general Date: Sun, 7 Apr 2024 20:48:54 -0400 Subject: [PATCH] fix and tweak limit mobs reached that player spawns from "code tweaks" * backport only the tweak of "code tweaks" of upstream commit 457eb1838cd1e694052298a42c84cd7b061d809d limit mobs reached that player spawns from creative or something * add the check for player before send the chat msg, missing from upstream --- api.lua | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/api.lua b/api.lua index 2f523c2..8c058f1 100644 --- a/api.lua +++ b/api.lua @@ -4546,11 +4546,16 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative) pointed_thing.under, under, placer, itemstack, pointed_thing) end - if pos - and not minetest.is_protected(pos, placer:get_player_name()) then + if pos and not minetest.is_protected(pos, placer:get_player_name()) then - if not minetest.registered_entities[mob] then - return -- TODO + if active_limit > 0 and active_mobs >= active_limit then + if is_player(placer) then + minetest.chat_send_player(placer:get_player_name(), + S("Active Mob Limit Reached!") + .. " (" .. active_mobs + .. " / " .. active_limit .. ")") + end + return end pos.y = pos.y + 1 @@ -4599,16 +4604,14 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative) if pos and not minetest.is_protected(pos, placer:get_player_name()) then - if not minetest.registered_entities[mob] then - return - end - -- have we reached active mob limit if active_limit > 0 and active_mobs >= active_limit then - minetest.chat_send_player(placer:get_player_name(), - S("Active Mob Limit Reached!") - .. " (" .. active_mobs - .. " / " .. active_limit .. ")") + if is_player(placer) then + minetest.chat_send_player(placer:get_player_name(), + S("Active Mob Limit Reached!") + .. " (" .. active_mobs + .. " / " .. active_limit .. ")") + end return end