InZan17 / Unloaded-Activity

When certain blocks such as crops or furnaces get out of simulation distance this mod will keep track of that so once the blocks get in again the mod will apply the changes it would have gotten if it never left the simulation distance.
https://modrinth.com/mod/unloaded-activity
GNU Lesser General Public License v3.0
17 stars 6 forks source link

SleepWarp Compatibility #2

Closed LeeroyGarfield closed 1 year ago

LeeroyGarfield commented 1 year ago

Can you make SleepWarp compatible? It's a mod that when you sleep, instead of skipping the night, it speeds up sleeping while also speeding up the simulation around you.

With SleepWarp, it seems your mod is slowing down sleep to a fixed rate throughout the night. I also found that it has no effect on farm growth outside of the simulation distance. Disabling your mod's random tick option solves the slowed down sleep problem, but without your mod's effect which is unfortunate.

So I wonder if it's possible for you to make both of them work together?

Love your mod!

InZan17 commented 1 year ago

Hello! I've released a new version of the mod which fixes this, though right now this version is only on github. You can download it here: https://github.com/InZan123/Unloaded-Activity-Fabric/releases/tag/v0.3.1 Tell me if you encounter any issues with this version.

Here's an explanation what the issue was.

Basically how my mod works is that every tick my mod checks the last time something was ticked. If the difference was more than the Tick Difference Threshold (which was 20) ticks it would simulate those ticks. And how SleepWarp works is that when you sleep it first adds 60 ticks to the time and then ticks everything 60 times.

This was a problem since when it adds 60 ticks to the time my mod would detect that and start simulating ticks. The consequences of this was that both my mod and SleepWarp would simulate time which would make crops grow double as fast and also the game to be really laggy making the time rate slow down.

The reason it's laggy is because my mod wasnt designed to be simulate a few ticks every tick (especially for every chunk within the simulation radius) but rather simulate tens of thousands of ticks once in a while.

A simple solution I did was to just increase the Tick Difference Threshold from 20 to 100 making SleepWarp time warping not exceed the threshold.

tl;dr

SleepWarp makes my mod simulate time every tick when sleeping making it laggy and I made it not do that anymore.

LeeroyGarfield commented 1 year ago

So, before the fix, SleepWarp acted as a multiplier for your mod, causing it to simulate unusually higher tick rates than normal whenever you sleep, but due to server limitations (perhaps, also depending on the specs), it couldn't keep up, causing the server to overload, thus making the game, including the sleep warp, laggy?

Anyways, the new version fixes it. I tested it including the farm, furnaces, baby animals and saplings. All seemed to simulate properly when I slept from afar. I also like that you made the tick difference threshold option customizable, since SleepWarp's maximum warp speed is 10 (default is 6) so I went to also test it with warp 10 at 100 threshold. The result was janky. But increasing the threshold to 300 seemed to have fixed it, though I haven't tested it any further as I went back to default setting shortly.

I think that's all I have to say. Everything is simulating properly. Thank you for the fix!

Edit: BTW, I'm using 1.19.4 Fabric. Sorry for not being clear in the beginning. Before I posted this issue, I was testing it with a lot of mods installed. This time though, I tested it in both the heavily modded MC and lightly modded MC (just some config apis, and optimization mods). I even went back to using the pre-fixed version on the lightly modded MC, and the result was still the same, slowed warped sleeping, etc.