@@ -4,20 +4,21 @@ import (
44 "encoding/binary"
55 "errors"
66 "fmt"
7- "github.com/df-mc/dragonfly/server/block/cube"
8- "github.com/df-mc/dragonfly/server/event"
9- "github.com/df-mc/dragonfly/server/internal/sliceutil"
10- "github.com/df-mc/dragonfly/server/world/chunk"
11- "github.com/df-mc/goleveldb/leveldb"
12- "github.com/go-gl/mathgl/mgl64"
13- "github.com/google/uuid"
147 "iter"
158 "maps"
169 "math/rand/v2"
1710 "slices"
1811 "sync"
1912 "sync/atomic"
2013 "time"
14+
15+ "github.com/df-mc/dragonfly/server/block/cube"
16+ "github.com/df-mc/dragonfly/server/event"
17+ "github.com/df-mc/dragonfly/server/internal/sliceutil"
18+ "github.com/df-mc/dragonfly/server/world/chunk"
19+ "github.com/df-mc/goleveldb/leveldb"
20+ "github.com/go-gl/mathgl/mgl64"
21+ "github.com/google/uuid"
2122)
2223
2324// World implements a Minecraft world. It manages all aspects of what players
@@ -597,11 +598,12 @@ func (w *World) SetTime(new int) {
597598 }
598599 w .set .Lock ()
599600 w .set .Time = int64 (new )
601+ timeCycle := w .set .TimeCycle
600602 w .set .Unlock ()
601603
602604 viewers , _ := w .allViewers ()
603605 for _ , viewer := range viewers {
604- viewer .ViewTime (new )
606+ viewer .ViewTime (new , timeCycle )
605607 }
606608}
607609
@@ -619,6 +621,16 @@ func (w *World) StartTime() {
619621 w .enableTimeCycle (true )
620622}
621623
624+ // TimeCycle returns whether time cycle is enabled.
625+ func (w * World ) TimeCycle () bool {
626+ if w == nil {
627+ return false
628+ }
629+ w .set .Lock ()
630+ defer w .set .Unlock ()
631+ return w .set .TimeCycle
632+ }
633+
622634// enableTimeCycle enables or disables the time cycling of the World.
623635func (w * World ) enableTimeCycle (v bool ) {
624636 if w == nil {
@@ -1050,7 +1062,7 @@ func (w *World) addWorldViewer(l *Loader) {
10501062 w .viewers [l ] = l .viewer
10511063 w .viewerMu .Unlock ()
10521064
1053- l .viewer .ViewTime (w .Time ())
1065+ l .viewer .ViewTime (w .Time (), w . TimeCycle () )
10541066 w .set .Lock ()
10551067 raining , thundering := w .set .Raining , w .set .Raining && w .set .Thundering
10561068 w .set .Unlock ()
0 commit comments