doc-bok / Butterflies

Adds pretty butterflies to the world.
https://www.bokmcdok.com
MIT License
4 stars 1 forks source link

Butterflies Spawn Too Much #109

Closed doc-bok closed 6 months ago

doc-bok commented 6 months ago

Added this to my 1.19.2 server. At first there were just a few butterflies here and there, great. Now I have an over abundance of butterflies in a singular area, some odd 1000+ in just a span of a 10 chunk region. This was all natural, as my server doesn't allow cheats / creative. This is a problem...

https://legacy.curseforge.com/minecraft/mc-mods/boks-butterflies?comment=29

doc-bok commented 6 months ago

Proposed Solution 1:

Fertility

Problem:

Modifications:

doc-bok commented 6 months ago

Proposed Solution 2:

More Predators

Problem:

doc-bok commented 6 months ago

Proposed Solution 3:

KISS

Problems:

Modifications:

doc-bok commented 6 months ago

Proposed Solution 4;

Chunk Limit

Problems:

doc-bok commented 6 months ago

Proposed Solution 5:

All of the Above

CRose91 commented 6 months ago

Tox here, did a bit of testing as I mentioned over on Curseforge, and I have some data for you.

First off, I like the solutions you came up with. Second, the data I have from my testing shows that the reason that my server was ultimately overrun with thousands of butterflies in a small area in a very short amount of time, was due to Minecrafts difficulty mechanics.

Your butterflies having short life spans ultimately keeps their numbers down currently, which is why only a handful had been seen on my server while adventuring / testing. The second that my testers and I switched the difficulty over to peaceful, the butterflies no longer had their "short lifespans" and the numbers greatly rose in a very short amount of time. Butterflies were not dying off, and continued to lay eggs. Those eggs hatched into more butterflies, which continued to not die off and also laid eggs. So on and so forth.

As a test and temporary solution, I set up a series of command blocks to run kill commands at a 5000 block area for a few of the butterfly varieties that had been overrunning my "home area", alongside their caterpillar and chrysalis stages. The problem with this is, its a very temporary solution as the eggs of said butterflies are not considered entities, and therefor any eggs remain, which continues the cycle of hatching, not dying, laying more eggs, and so forth.

Continuing my testing, I switched the difficulty back to easy or higher, and rather than my command blocks killing off hundreds/ thousands, its now killing less than 10-20 consistently, which means the difficulty setting being set higher than peaceful is managing the butterfly numbers.

In conclusion, its not feasible to use the mod in its current state on servers, so long as the difficulty is set on peaceful for any extended period of time as the numbers are in multiples of however many eggs each butterfly can currently lay. Even set to two eggs per life cycle for example, being set on peaceful the butterflies would still be in multiples of 2. It would just take a little more time for the numbers to reach the thousands. If the difficulty is set to easy or higher, it seems to be fine.

Edit: Also, my trees look like swiss cheese now. :c

doc-bok commented 6 months ago

Wow, thanks for doing all that testing! So it actually seems that the real fix is to ensure that butterflies "die" even on peaceful, or at least don't multiply. I always assumed that peaceful only affected players - I'm surprised it affects mobs as well.

doc-bok commented 6 months ago

Okay, so I'm not having any luck testing this locally. I can get the butterflies to die in peaceful mode locally, both with client only and client/server. Could you be doing anything else or using another mod that might affect this?

From digging into the code the things that could prevent them from dying would include the following:

CRose91 commented 6 months ago

Not a problem, as a coder/ creator myself, I enjoy troubleshooting and testing as it allows me to further my knowledge, which is handy for future projects. It seems the way minecraft was coded, the constant health regen that is in effect with the peaceful difficulty is simply for entities in general, which would include both players and mobs. However if them dying off is a result of a kill command similar to what I was using rather than slowly losing health over time, than that constant health regen from peaceful shouldnt have an effect. I just assumed that since it only happened -after- my server was switched to peaceful, and switching it back to other difficulties resulted in a more normalized amount of them, than difficulty level played a role. And it still might be playing a role in some way, but with your local testing yielding different results, than as you thought there must be something that I am doing differently, or perhaps another mod I am using playing a role.

I will do some more testing and go through my mods and see if any of them would have any role whatsoever in the butterflies behaviors. I don't think there is, but never know. Ill test other animals as well, however I don't believe aging plays a role here, due to the shear numbers while in peaceful and I was also having to use the kill commands on both the Caterpillar and Chrysalis forms as well. If aging played a role, than the vicious infinite cycle of butteflies laying eggs and becoming new butterflies to lay more essentially multiplying the numbers constantly wouldn't be a factor. Something, somewhere, was preventing the death of butterflies, and as mentioned I had assumed it to be the changing of difficulty to peaceful.

Not sure about persistence, as the two testers I have don't have access to creative mode, only me, I haven't touched changing gamemodes myself, therefore nothing would have been spawned via creative spawn eggs. They don't have access to creative because the testing we are currently doing is more so along the lines of making sure that the mods chosen for my modpack, are playing nice with one another, and from my experience, that is completely different with local and server.

As mentioned, I will continue testing and doing a little research into mods that might be affecting the butterflies.

doc-bok commented 6 months ago

Okay, I've been playing a bit more with the mod recently, and I'm noticing that if the conditions are right, the butterflies will multiply very quickly. I have a small area (around a chunk or 2) that has well over a few dozen butterflies right now. I don't think the game being in Peaceful has any effect on this - it's not that they don't die, just that too many spawn. I'm going to implement the ideas here - I think the chunk limit in particular will help keep things under control.

I'm also going to look at adding some configuration for this as well, so that servers can modify exactly how often butterflies spawn/spread, or even disable it entirely.

doc-bok commented 6 months ago

Proposed Solution 6:

Butterfly Movement