]> git.lizzy.rs Git - Crafter.git/commitdiff
Stop mob spawners from creating insane amounts of mobs
authoroilboi <47129783+oilboi@users.noreply.github.com>
Tue, 30 Jun 2020 10:34:22 +0000 (06:34 -0400)
committeroilboi <47129783+oilboi@users.noreply.github.com>
Tue, 30 Jun 2020 10:34:22 +0000 (06:34 -0400)
mods/mob_spawners/init.lua

index 3c3d739d080e0087ea33ffcf3a4ce9cb062245a9..a6779ac82357ad7ce77db99f1e4097f020ab1c15 100644 (file)
@@ -62,6 +62,17 @@ function register_mob_spawner(mobname,texture,mesh)
                 minetest.add_entity(pos, "mob_spawners:"..mobname)
             end
 
+            local player_found = false
+            for _,object in ipairs(minetest.get_objects_inside_radius(pos, 7)) do
+                if object:is_player() then
+                    player_found = true
+                end
+            end
+
+            if not player_found then
+                return
+            end
+
             local mobcount = 0
             for _,object in ipairs(minetest.get_objects_inside_radius(pos, 10)) do
                 if not object:is_player() and object:get_luaentity().mobname then