Alex's Mobs

Alex's Mobs

72M Downloads

Leafcutter anthills infinitely spawns ants

Carro1001 opened this issue ยท 7 comments

commented

Like actually infinite, 100+ ants just infinitely come out of 1 nest sometimes

commented

Didn't want to create a new bug report for this so I will just post this here. I came across this issue today and I haven't really done anything special it seems there is no cap on the number of leafcutter ants spawning.

I was playing and noticed lag and running /forge tps I saw my TPS was around 5. Ran the TPS profiler and saw the following.
https://i.ibb.co/T0bsBQM/2022-03-01-03-11-39.png
https://i.ibb.co/TM4kDc6/2022-03-01-03-12-21.png
https://i.ibb.co/WDHcRVJ/2022-03-01-03-11-27.png

There are only 2 ant hills in this area and when I ran /kill @e[type=alexsmobs:leafcutter_ant] it killed 644 entities.

I didn't place any anthills and this is actually a new single player instance I have been playing for a few hours. So this is from regular worldgen. I don't think it took very long for it to get to this point - maybe about an hour? I recall walking by the area about an hour ago so it loaded the two anthills in and then I guess just continued to infinitely spawn the ants.

There was a single anthill next to my base and I noticed the ants were getting a bit out of control (before it got to the point in the pictures) so I killed the queen to stop the spawning.

I'm playing in the All The Mods 7 pack (version 7-0.2.45) and it is running the current version (1.17.1) of Alex's Mobs.

Upon looking around on reddit it seems this issue has been around for a while?
https://www.reddit.com/r/feedthebeast/comments/ovmm5u/i_swear_i_set_the_colony_size_limit_to_20/

Although - looking at this post it seems like some people tracked this issue down to a 'performance enhancing' mod that is supposed to help but really removes the spawn caps on some mods.
https://www.reddit.com/r/feedthebeast/comments/msr7rf/so_many_mobs_spawning_oh_the_biomes_youll_go/

commented

Do you have mobgriefing turned off? Trying to figure out what causes this

commented

spawns as in worldgen or placed? under what conditions

commented

No, mobGriefing is currently set to true.

commented

I actually came here to report this myself and noticed it was already open. I'm playing on the All The Mods 7 modpack in a single player world. The mod version is alexsmobs-1.17.5. I was only like 5 or 6 hours into the pack when I started noticing tons of lag. TPS was down to 9. I ran a spark profiler and turns out leafcutter ants were showing at 58% usage. So I ran the kill command on them and it cleared like 300 mobs. The problem still persisted though. Turns out the kill command only worked for ants that were outside the hive. I ended up finding the hive and did another kill command. It killed the ants that were outside of the hive but immediately, more started pouring out. So I had to destroy the hive and kill the queen. Then it all cleared up. This was all from 1 hive.

commented

mobGriefing off here (which by the way the ants seem to ignore and eat all the leaves anyway), and this just happened in a completely untouched piece of jungle shore:
image

note other anthills i encountered did the same, but slower so i didn't notice outright.

/kill @e[type=alexsmobs:leafcutter_ant] said 726!

while this is being worked on, is there a way of simply limiting e.g. the amount of equal entities per chunk or something? i don't want to outright disable all ants but... this is ridiculous and about to eat my world!

EDIT: I just wrote this CraftTweaker script, which should (no warranty and all that!) keep them in check:

import crafttweaker.api.events.CTEventManager;
import crafttweaker.api.event.entity.EntityJoinWorldEvent;
import crafttweaker.api.event.living.LivingUpdateEvent;
import crafttweaker.api.entity.Entity;
import crafttweaker.api.util.math.BlockPos;
// Every time an Entity "joins" (spawns) the World...
CTEventManager.register<crafttweaker.api.event.entity.EntityJoinWorldEvent>((event) => {
	val level = event.world;
	var range = 64;
	var nospawnNumber = 20 as usize;
	var cullingNumber = 25 as usize;
	// If it's an Ant...
	if event.entity.getType() == <entitytype:alexsmobs:leafcutter_ant> {
		var pos1 = new BlockPos(event.entity.blockX-range, event.entity.blockY-range, event.entity.blockZ-range);
		var pos2 = new BlockPos(event.entity.blockX+range, event.entity.blockY+range, event.entity.blockZ+range);
		// Get all Ants in the 64 block range...
		var ents = level.getEntities(event.entity, pos1.x, pos1.y, pos1.z, pos2.x, pos2.y, pos2.z, e => e.getType() == <entitytype:alexsmobs:leafcutter_ant>);
		// if there are more than 20...
		if(ents.length > nospawnNumber){
			// don't allow it to "join"
			event.cancel();
		}
		// if there are more than 25...
		if(ents.length > cullingNumber){
			// kill them all
			for ent in ents {
				ent.kill();
			}
		}
	}
});

this should both limit their numbers, and cull every one outside the hill as soon as they're getting out of hand (or if they were still out of hand from an earlier save)

you might have to change the range value to adjust for performance impact vs. effectiveness (higher values require to search a larger area, lower values might miss ants if they wander too far and still keep spawning way above the target number)