McJtyMods / InControl

Be In Control of Mob Spawns and others
MIT License
46 stars 17 forks source link

Mob limiting with perchunk tag is functioning weirdly #442

Open Razor235T opened 2 months ago

Razor235T commented 2 months ago

Minecraft 1.20.1, Forge 47.3.5, InControl 9.2.6. Controlled with no other mods installed in singleplayer world. For example, the code: [ { "mob": ["minecraft:zombie", "minecraft:husk"], "spawner": true, "when": "onjoin", "result": "default" }, { "mob": ["minecraft:zombie", "minecraft:husk"], "mincount": { "amount": 1, "perchunk": true }, "when": "onjoin", "result": "deny" } ]

I don't think there is a mistake since the code is functioning. However, it limits the zombies with amount*9, in singleplayer flat world. So I can spawn 9 zombies totally. If I set amount to 2, I can spawn for some reason 19 zombies. And the amount can vary depending on mobs and mods. It is quite frustrating, because I want very tight control over the mobs from mods that bring a lot of difficulty to the game, like Monsters plus or Hostile mobs improve over time.

McJty commented 2 months ago

From the wiki:

perchunk: if this is true the amount will be scaled with the amount of loaded chunks divided by 289 (this is how vanilla mobcap works)

Did you correct to 289?

Razor235T commented 2 months ago

I don't get what you mean, but vanilla scaling works by formula mobcap loaded chunks / 289. I checked in singleplayer, so loaded chunks are 289. So we have 1 mob 289 chunks / 289 chunks. But I can spawn 9 zombies with that piece of code.

McJty commented 2 months ago

What's your view distance set at?

Razor235T commented 2 months ago

14 chunks. I don't think vanilla mobcap depends on that. Edit: sorry, 12 chunks is set on the client, which I checked the piece of code on.

McJty commented 2 months ago

It actually does. See this page: https://minecraft.fandom.com/wiki/Spawn#:~:text=Most%20mobs%20have%20a%20spawning,mobs%20(animals)%20spawn%20rarely.

Quote: The cap is scaled by the total number of chunks within a 17×17 chunk square around any player. The cap is then scaled as globalCap = mobCap × chunks ÷ 289.

In Control tries to mimic the same behaviour

Razor235T commented 2 months ago

If you mean that my loaded chunks are 12x12, then globalCap = 1 * 144 / 289, which is around 0.5.

Also I don't see where it says about a distance view. I can see there, that if view distance is below 9 then mobs are spawning less frequently. But my issue is that the zombies spawn too often

McJty commented 2 months ago

A view distance of 12 means 12 chunks in every direction. So that means (12+12+1)*(12+12+1) chunks and that's 625

Razor235T commented 2 months ago

Okay, it starts to make sense. But you the quote says the cap is scaled by the total number of chunks "within" 17x17 chunk square around a player. So for one player the cap should be 17x17 square.

Razor235T commented 2 months ago

Monsters can't spawn outside the 8 chunk view distance. image So if I set view distance on a server to more than 8, minecraft won't let more mobs to spawn. It counts only the 17x17 square. But Incontrol will increase the cap