[Feature] Chunk Loading
Electrocutor opened this issue · 18 comments
While the presence of dynamic chunk loading is not foreign to mods that require it, the current implementation of MineColonies does not include a dynamic chunk (un)loader. It also does not include any mechanisms that work around a need for it.
Examples:
*Note that this list is not all-inclusive
- NPC Work Hut is in unloaded chunk
- NPC Work required destination is in unloaded chunk
- NPC Home Hut is in unloaded chunk
- NPC Home and Work are separated far enough that both Home and Work are never both loaded
- This is one of the largest problems as even if you are actively working in various parts of your colony, the NPC is very rarely able to both load up from home and make it to work during a day
Possible Ideal Solution:
The ideal solution would be to come up with or use an existing dynamic loader/unloader so that the volume around NPCs is always loaded. This is how mods like RailCraft are able to send trains across the map even if players are not actively riding it. Using such a solution requires that optimizations be made to ensure that the amount of CPU cycles spent on NPC-only chunks is minimal.
Possible Work-Arounds:
Aside from an ideal solution, there is the possibility of a non-ideal workaround. One example might be that any Work Hut within the loaded chunks range of the player will auto-spawn their assigned worker if that worker's current location is outside the loaded chunks range. Another might be that the chunk in which the Town Hall is located will never unload, so as to ensure that all home/work huts within that short range will always function while the player is logged in.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
I use ExtraUtils2 for persistent chunk loading. I have verified via chicken chunks that my entire colony stays loaded. However, if I get out of view of the workers, they stop moving. They resume when I approach them again. If I leave the area and return, nothing has changed since leaving and majority of the time I must recall my citizens at the town hall for they are nowhere to be seen. I'm running latest 1.10.2 version. Is this intended or am I encountering a bug?
Yeah them stopping is not something we do. Entities just stop. In Minecraft when they are too far away from the player.
Thank you for the prompt response. Is there any way around that? I increased my colony radius and have things a little spread out. I have to pick a side to hang around for that set of workers to get anything done. I'd like to keep them going at all times if it's possible. I only play on SSP if that has any relevance.
On a side note, every time I load the world I have to recall the citizens due to them not being loaded.
No, I do not. I did some research on it a while back and saw many problems it was having and never revisited it. Is there something you suggest that includes it or are you looking for where I might have something causing a possible issue?
Nothing that I know of that completes such a task.
List of mods:
Forge
Optifine
Jei/nei
Ccl-entityhook(part of codechicken ?)
Car mod
Codechicken lib
Codechicken core
Chickenchunks
DrZhark's custom spawner
Customoregen
Mo'creatures
Endercore
Ender io
Extra utilities 2
Forge essentials client addon
The one probe
Immersive engineering
Immersive petroleum
Immersive railroading
Track api
Malisis core
Malisis doors
Malisis switches
Radixcore
MCA
Livelihoods
Minecolonies
Vic's Modern warfare
Harvestcraft
Progenitor
Realistic survival
Rikmulds core
RTG
simulated nights
The camping mod 2
Tough as nails
Trapcraft
Tree chopper
World edit
Xaero's minimap
Xaero's world map
I am also very adamant about reading all documentation about the mods I use and thoroughly examine, and alter as needed, configuration files.
Yeah that's something we often discussed.
And we decided against dynamic chunk loading.
Since our mod is often used in smp that kind of things would be quite resource heavy.
As well as for low end computers.
So people who wish chunk loading can install mods which do that for them and place them inside the colony borders.
I have been looking into this. And @Raycoms their is a small but not insignificant problem with your reasoning. Yes it is correct that keeping a chunk loaded take a bit more resources which would make minecolonies heavier to play, how ever as for now we have a lot of mechanics which really on the fact that they operate in a completely loaded colony (barbarians is an example, but also the food system, and the future request system are going to rely on it). This in itself is of course not wrong, you would not want to exclude a specific area from the colony for a specific function. However this also means that colonies should and can not be loaded half way. We need to provide a way to make sure that a goven colony is completely loaded and unloaded, and not partially. This effect is especially evident when we do stuff in the WorldTickEvent handler in unloaded colonies. Minecraft handles this by loading the chunk for a brief moment (roughly 10 seconds everytime we need something in a unloaded chunk), this behavior puts a lot more stress on the servers then just keeping them loaded in the first place.
So I see two things wrong with your assumption that it is not needed:
First and Foremost: We assume a fully loaded colonies in several systems.
Secondly: We are loading chunks anyway in a case that a colony is partially loaded (being it by a player or because it is partially with in the spawn chunks) causing a lot more stress then we would cause when we kept the colonies chunks loaded when at least one chunk of it is loaded anyway.
I think if we were to do this, it would have to be for only Players that are online (yes, I know, pointing out the obvious). Also, I think if a player wanders away from their colony (Say 50 - 100 blocks from the border) the colony gets unloaded. Also, I think that if we want to do this, we should look into Optimising more the citizens, because currently the citizens are pretty lag inducing (From the server: entity.EntityCitizen | 5.358 Time/Tick | %49.822 of Tick
). I would love to (At some point) take a look at the Citizen AI/classes.
Also, i do think that this should definitely be a config option, obviously with a big warning, saying that if it is disabled some features may not work, and will probably break things
yeah, that's my main reason for a config option. Because in SSP it'd work pretty well (On medium end comps)
What about changing the AI from being tick-based to event-based; then simply using tick to determine which events to fire when they are needed. For example, if an NPC is currently trying to walk from point A to point B, there is no reason to run a great deal of other logic until they reach their destination except for specific things that should interrupt them, such as monster entering proximity or night falling. What's more, something like 'Monster Enter Proximity' could be an event instead of being checked with every tick.
You could even spread out the tick code into a sub-function so that the tick code would only run every randomized 1 to 5 tick, thus reducing server load by 80% by this alone and separating multiple NPCs code runs into different time brackets. Doing this would require that you track how many ticks passed between each code run though so as to properly account for things like healing or what not.
You could also use this method dynamically for servers, so if x amount of NPCs are active, their code runs every x/n ticks. Thus, the more active NPCs there are on a server, the greater the span of time there is between logic re-calculating.
Just wanted to leave a hint here for anyone coming across this. After reading a bit, I understand that chunk loading has been revised in 1.14, meaning that for the colony to be loaded and functioning, a "ticket level" of 31 or lower is required in all chunks that villagers may wander into. This should be possible with newer chunk loading mods without issue. Alternatively, /forceload
may be used, just check how the tickets propagate as to make sure not too much is loaded.