Minecraft-Java-Edition – How to Track the Number of Alive Mobs Using Commands in Minecraft

minecraft-commandsminecraft-java-editionminecraft-redstone

I've been building a Minecraft map where you fight bees(yes I know I'm a cold-hearted person) and I'm trying to figure out a way so it stops spawning more bees when there is a certain amount(I don't want the player to get overwhelmed) here is a video of some gameplay if this helps:

It seems that some people have misunderstood so I will elaborate on some points:

1.each bee is summoned by a command block every 24 Redstone ticks (~2.4 seconds)

2.I am planning on publishing this map

3.This is a very early prototype with plenty of room for improvement

Here is a video showing the redstone:

Best Answer

I figured out that if I summon an armor stand on a pressure plate(heavy) every time a bee is summoned it tells me how many bees there and once a certain amount of bees are summoned I can make things happen: