1+ /*
2+ * Copyright 2026 Lambda
3+ *
4+ * This program is free software: you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation, either version 3 of the License, or
7+ * (at your option) any later version.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+ package com.lambda.module.modules.render
19+
20+ import com.lambda.event.events.PacketEvent
21+ import com.lambda.event.events.TickEvent
22+ import com.lambda.event.listener.SafeListener.Companion.listen
23+ import com.lambda.module.Module
24+ import com.lambda.module.tag.ModuleTag
25+ import net.minecraft.network.packet.s2c.play.WorldTimeUpdateS2CPacket
26+
27+ object Time : Module(
28+ name = " Time" ,
29+ description = " Changes the time of day" ,
30+ tag = ModuleTag .RENDER
31+ ) {
32+ private val time by setting(" Time" , 12000L , 0L .. 24000L , 100L )
33+
34+ private var prevTime = 0L
35+
36+ init {
37+ onEnable { prevTime = world.levelProperties.timeOfDay }
38+ onDisable { world.levelProperties.timeOfDay = prevTime }
39+
40+ listen<TickEvent .Pre > {
41+ world.levelProperties.timeOfDay = time
42+ }
43+
44+ listen<PacketEvent .Receive .Pre > { event ->
45+ if (event.packet !is WorldTimeUpdateS2CPacket ) return @listen
46+ event.cancel()
47+ }
48+ }
49+ }
0 commit comments