This commit is contained in:
Adrian Siekierka 2025-06-02 15:35:10 +02:00
parent 5d35d7f9e1
commit a31f90a088
3 changed files with 11 additions and 8 deletions

View File

@ -1,5 +1,6 @@
## Fixes/improvements
* [#3621] Fix `os.time()` being off by one hour
* [#3682] Add error handling to the `flash` OpenOS program
* [#3764] Fix left and right names being swapped in the Rack GUI
* [#3779] Fix `os.sleep(0)` causing `too long without yielding` (Ocawesome101)

View File

@ -67,10 +67,11 @@ class OSAPI(owner: NativeLuaArchitecture) extends NativeLuaAPI(owner) {
if (lua.isNoneOrNil(1)) {
// Game time is in ticks, so that each day has 24000 ticks, meaning
// one hour is game time divided by one thousand. Also, Minecraft
// starts days at 6 o'clock, versus the 1 o'clock of timestamps so we
// add those five hours. Thus:
// timestamp = (time + 5000) * 60[kh] * 60[km] / 1000[s]
lua.pushNumber(((machine.worldTime + 5000) * 60 * 60) / 1000.0)
// starts days at 6 o'clock; os.time() reflects UTC while os.date()
// reflects the local time zone, but Minecraft has no concept of
// time zones, so this detail can be ignored. Thus:
// timestamp = (time + 6000) * 60[kh] * 60[km] / 1000[s]
lua.pushNumber(((machine.worldTime + 6000) * 60 * 60) / 1000.0)
}
else {
def getField(key: String, d: Int) = {

View File

@ -51,10 +51,11 @@ class OSAPI(owner: LuaJLuaArchitecture) extends LuaJAPI(owner) {
if (args.isnoneornil(1)) {
// Game time is in ticks, so that each day has 24000 ticks, meaning
// one hour is game time divided by one thousand. Also, Minecraft
// starts days at 6 o'clock, versus the 1 o'clock of timestamps so we
// add those five hours. Thus:
// timestamp = (time + 5000) * 60[kh] * 60[km] / 1000[s]
LuaValue.valueOf((machine.worldTime + 5000) * 60 * 60 / 1000)
// starts days at 6 o'clock; os.time() reflects UTC while os.date()
// reflects the local time zone, but Minecraft has no concept of
// time zones, so this detail can be ignored. Thus:
// timestamp = (time + 6000) * 60[kh] * 60[km] / 1000[s]
LuaValue.valueOf((machine.worldTime + 6000) * 60 * 60 / 1000)
}
else {
val table = args.checktable(1)