What does this mod do?
In Minecraft, when you go far away from chunks, they'll stop being simulated. Later when you return, stuff like crops will not have grown at all, baby animals will still be babies, and the items you were cooking will still be cooking.
This mod changes that by simulating blocks and entities once they get within simulation distance to catch up after being unloaded for a period of time. It'll be as if they've always been simulated!
This also works when you're skipping the night. Instead of waiting for your iron to cook, or for your crops to grow, you can skip the night to speed up the process!
How exactly does it work?
Every time a chunk, entity, or block entity gets ticked, it will save the current time, and also check how long it's been since it was last ticked. If the difference is large enough, my mod will start simulating it to make it catch up.
But wont that lag the game if it has to simulate all that missed time?
Not if you're smart! Instead of repeatedly running the tick function for every tick that was missed, Unloaded Activity will instead directly calculate the state of the block given the amount of ticks missed. So if a block missed 24000 ticks (1 Minecraft day), instead of trying to tick it 24000 times, it will do a little bit of math and be done.
This is way faster, but comes at the cost of needing to re-implement the tick logic in this new way. This is why some modded crops may grow incorrectly, or not at all. If you find a modded block that simulates incorrectly, you can blacklist that block from the mod, but also please create a bug report!
What about blocks with random/precipitation ticks? Those have randomness to them.
To simulate these blocks, the mod will sample a random number from a binomial distribution and then use that to update the state of the block. However, sometimes the probability of success changes. Then we need to sample random numbers from a negative binomial distribution to simulate the duration of each success.
Unsupported blocks and entities
Not everything in vanilla Minecraft is supported. Here's which ones are unsupported and the reason for it:
- Every redstone related block
Redstone logic is too complicated for me, and even if I were to try to support it, I would most likely break a lot of existing redstone contraptions. - Brewing stands
Brewing stands only has 1 ingredient slot. Because of this, Unloaded Activity would only be able to simulate 1 ingredient before having to stop, and I think brewing stands are quick enough to not need to be supported. Unless you immediately fly away with an elytra or sleep after turning on a brewing stand, you wouldn't really notice the lack of support. - Campfires
Same reason as brewing stands. - Dropped items despawning
I feel like this would ruin the game. If you die far away from your base you'd have no way of retrieving your items, even if you knew exactly where they were. - Beehives
This block is unlike any other blocks that's supported, since this block requires entities (bees) to do their own stuff to work. I also haven't looked into it too much yet, so it might get supported in the future.
For any other blocks or entities that aren't supported and that aren't listed here, I've simply just forgotten about. So please let me know if I've forgotten anything!
Inspiration
I got this idea from a video by DigiDigger where he talks about how Terraria handles all of its tiles. Even though the video isn't really accurate to how Terraria actually works, he did bring up an optimization which I feel like could be implemented in Minecraft. The timestamp where he talks about this optimization is at 5:11.
Feedback / Suggestions
If you got any feedback or suggestions for this mod, feel free to join my discord server!