BG-Software-LLC / WildLoaders

Very optimized and highly configureable chunk-loaders plugin!
https://bg-software.com/wildloaders/
GNU General Public License v3.0
27 stars 13 forks source link

Entities keeps spawning overloading the server #66

Closed naBBolethano closed 1 year ago

naBBolethano commented 1 year ago

Minecraft's Version

1.19.3 - purpur-1.19.3-1912

Plugin's Version

WildLoaders-2022.7-b70

Describe the bug

Placed a small loader in the same chunk of a iron golem farm, after approx. 12h with no players on more than 24 thousand entieties spawned in that chunk causing the server to overload. The main issue isn't the entities spawn as i think should be an as expected feature, the issue is that they don't automatically despawn.

To Reproduce

can be reproduced by placing a chunk loader and leaving the area. No additional steps required.

Additional Information

2023-02-15_12 06 22

naBBolethano commented 1 year ago

2023-02-15_15 05 36

this image gives a better understanding of the issue, basically the mobs spawn inside the 5x5 chunk area loaded by the loader and the plugin works as intended and this is expected behavior. The issue is that when the enteties travel to unloaded chunks they keep accumulating until the chunks are finally loaded. This causes a critical issue that makes the plugin unusable in almost every scenario.

There are some potential fixes that I have thought of.

1. Add an option to exclude certain mob to spawn inside these chunks when not loaded by a player. This is not an actual fix but can help mitigate the issue.

  1. If mobspawned >x then stop spawning new entities unless generated by a mobspawner (this option needs a toggle on/off option or it will break mob farms)

  2. Add noAi nbt tag to mobs spawned when the chunk is loaded by the loader. This will stop mobs moving in unloaded chunks and the spawns will stop due to max entities in a defined area (not a 100% fix because then you will have chunks full of dumb asf mobs but still better than nothing)

  3. this is the best option I think but it needs to get taken with a bit of salt because I don't have a really good understanding of this mechanic. Chunk should have vanilla-like load type assigned. 5x5 chunks should be loaded with a 31 load level, instead of not loading at all the 6th chunk circle it should be loaded with a 32 load level. This load level stops entites from being processed (they do not move).

as stated in the wiki "For example, in a single-player game with a simulation distance of 5 chunks, an area of 7×7 chunks centered around the player has a load type of entity ticking (level 31). The strip of chunks at the outer edge of a 9×9 perimeter surrounding the player have ticking (level 32), and the next enclosing chunks (11×11 perimeter) are border chunks (level 33)".

If I'm not wrong, entites immediately despawn when they are ~128 blocks away from the player (this means they are in the load level 32 area) also mobs further than 32 blocks from the player have a chanche to despawn.

Now, if it's possible to replicate this vanilla mechanic in the plugin it's done, that's it. If it's not possible the best way to simulate this behavior is by loading 7x7 chunks and stop processing entities in the borders chunk. If this is not possible, the last thing would be killing them.

If i come up with other solutions I'll be happy to update the ticket

OmerBenGera commented 1 year ago

In newer versions of the game (including 1.19), when loading chunks, the surrendering chunks are loaded in different level - this load level makes entities stay at their position and not move (read more on the wiki page of minecraft) Therefore, entities that go to "unloaded" chunks A) not actually go to unloaded chunks B) not loading them.

The lag you mentioned might be because of many mobs spawn, which is what can happen when you keep a chunk loaded for a long time. This is an expected behavior of the plugin - it might not be suitable for your server. I'd advice you to use stacker plugin.