CC: Tweaked

CC: Tweaked

57M Downloads

os.epoch() sometimes calculates the in-game time incorrectly

Jeuvke opened this issue ยท 3 comments

commented

MC version: 1.16.4
Forge version: 35.1.13
CC:T version: 1.94.0

os.epoch("ingame") sometimes calculates the in-game time wrongly when used with os.date(). This seems to occur randomly when there have been many days played (high time value) and time gets skipped (through sleeping).
The time shown by os.date("%H:%M,os.epoch()/1000) can be off by up to 12 hours.

Other mods used:
Astral sorcery, version 1.13.6
Autoreglib, version 1.6-47
Botania, version 1.16.4-410
Curios, version 4.0.3.0
JEI, version 7.6.0.62
Observerlib, version 1.4.4
Patchouli, version 1.16.4-48
Psi, version 1.16-88

commented

How high is 'high time value'? What in-game day does F3 report?

commented

If you can, I'd recommend not using os.date with in-game time - instead use os.time/os.day directly.

os.date is designed to operate on the Unix epoch (utc, local), specifically on UTC and your local timezone. Minecraft time is obviously in neither of those, so the result most likely won't make sense.

Most crucially, the unix epoch measures from midnight, while the in-game one works from 6 am. os.date can't tell the difference, and so is going to spit out some very inaccurate values.


Note to self, this line will quite likely overflow. We should probably use a long literal and cast there instead. Not sure if this is causing the problem, but worth fixing anyway.

commented

How high is 'high time value'? What in-game day does F3 report?

About 2000 days, so quite high.