realweather/notes.txt
2024-09-24 19:57:21 +02:00

73 lines
1.5 KiB
Text

goal: realtime to in game time conversion
There is no need to keep days
minecraft day is 0 - 24000 ticks
where 6000 ticks is noon (peak sun) and 18000 is midnight (peak moon)
irl day is 0 - 86400 seconds
0. s = epoch % 86400 to get seconds since midnight
^
(* scale) here
1. t = s / 72.0 to fit into minecraft day
2. t = t * 20 to convert that to ticks
3. t = t - 6000 to align noon and midnight
this leaves us with negative time, so
4. t = floorMod(t, 24000) to wrap if negative
example:
epoch = 1713593340
0. getting seconds since midnight
s = epoch % 86400
s = 1713593340 % 86400
s = 22140
1. conversion to minecraft day length
gs = s / 72.0
gs = 22140 / 72.0
gs = 307.5
2. to ticks
t = gs * 20
t = 307.5 * 20
t = 6150
3. step 3
t = t - 6000
t = 6150 - 6000
t = 150
4. wrapping
t = floorMod(150, 24000)
t = 150
goal: frequency of time update
t = 72 / scale
t is the period, in ticks of course
to see how many irl seconds a tick represents:
s = 3.6 * scale
(from 1 / (1/72 * 20 * scale))
however, some scales result in fractions
here's how many in game aligned seconds have passed at the end of a real day:
84000 / 72 * scale * floor(72/scale)
for scale 0.99: 83160
so we'll be 14 minutes behind
solution? for now let's warn and update time every tick
to check:
scale * floor(72/scale) == 72
goal: offsetting by player position
t = (longitude / 15) * 1000 * scale
accounting for sunrise and sunset
TODO, idk yet without
update: this is now possible with 0.8.0 api