Skip to content

Commit fc088e8

Browse files
committed
Add ClientSideTime module
This patch adds the ClientSideTime module, which allows the user to change their client-side world time. It currently has two modes; TICKS and REAL_WORLD_TIME. The former allows you to specify the world time as ticks, and the latter uses your current computer time as the world time :)
1 parent c819baa commit fc088e8

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

src/main/java/com/lambda/mixin/world/MixinWorld.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.lambda.mixin.world;
22

33
import com.lambda.client.module.modules.misc.AntiWeather;
4+
import com.lambda.client.module.modules.render.ClientSideTime;
45
import com.lambda.client.module.modules.render.NoRender;
56
import net.minecraft.util.math.BlockPos;
67
import net.minecraft.world.EnumSkyBlock;
@@ -32,4 +33,10 @@ private void getRainStrengthHead(float delta, CallbackInfoReturnable<Float> cir)
3233
cir.setReturnValue(0.0f);
3334
}
3435
}
36+
37+
@Inject(method = "getWorldTime", at = @At("HEAD"), cancellable = true)
38+
public void onGetWorldTime(CallbackInfoReturnable<Long> cir) {
39+
if (ClientSideTime.INSTANCE.isEnabled())
40+
cir.setReturnValue(ClientSideTime.INSTANCE.getUpdatedTime());
41+
}
3542
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.lambda.client.module.modules.render
2+
3+
import com.lambda.client.module.Category
4+
import com.lambda.client.module.Module
5+
import java.text.SimpleDateFormat
6+
import java.util.*
7+
8+
object ClientSideTime : Module(
9+
name = "ClientSideTime",
10+
description = "Change the client-side world time",
11+
category = Category.RENDER
12+
) {
13+
private val mode by setting("Mode", ClientSideTimeMode.TICKS)
14+
private val time by setting("Time", 0, 0..24000, 600, { mode == ClientSideTimeMode.TICKS })
15+
16+
enum class ClientSideTimeMode {
17+
REAL_WORLD_TIME, TICKS
18+
}
19+
20+
@JvmStatic
21+
fun getUpdatedTime(): Long {
22+
if (mode == ClientSideTimeMode.REAL_WORLD_TIME)
23+
return dateToMinecraftTime(Calendar.getInstance())
24+
return time.toLong()
25+
}
26+
27+
private fun dateToMinecraftTime(calendar: Calendar): Long {
28+
// We subtract 6 (add 18) to convert the real time to minecraft time :)
29+
calendar.add(Calendar.HOUR, 18)
30+
val time = calendar.time
31+
val minecraftHours = SimpleDateFormat("HH").format(time)
32+
val minecraftMinutes = (SimpleDateFormat("mm").format(time).toLong() * 100) / 60
33+
return "${minecraftHours}${minecraftMinutes}0".toLong()
34+
}
35+
}

0 commit comments

Comments
 (0)