-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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 :) * Rename --------- Co-authored-by: Constructor <fractalminds@protonmail.com>
- Loading branch information
1 parent
9aebfc0
commit b3175e2
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/kotlin/com/lambda/client/module/modules/render/TimeWarp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.lambda.client.module.modules.render | ||
|
||
import com.lambda.client.module.Category | ||
import com.lambda.client.module.Module | ||
import com.lambda.mixin.world.MixinWorld | ||
import java.text.SimpleDateFormat | ||
import java.util.* | ||
|
||
/** | ||
* @see MixinWorld.onGetWorldTime | ||
*/ | ||
object TimeWarp : Module( | ||
name = "TimeWarp", | ||
description = "Change the client-side world time", | ||
category = Category.RENDER | ||
) { | ||
private val mode by setting("Mode", TimeWarpMode.TICKS) | ||
private val time by setting("Time", 0, 0..24000, 600, { mode == TimeWarpMode.TICKS }) | ||
|
||
enum class TimeWarpMode { | ||
REAL_WORLD_TIME, TICKS | ||
} | ||
|
||
@JvmStatic | ||
fun getUpdatedTime(): Long { | ||
if (mode == TimeWarpMode.REAL_WORLD_TIME) | ||
return dateToMinecraftTime(Calendar.getInstance()) | ||
return time.toLong() | ||
} | ||
|
||
private fun dateToMinecraftTime(calendar: Calendar): Long { | ||
// We subtract 6 (add 18) to convert the real time to minecraft time :) | ||
calendar.add(Calendar.HOUR, 18) | ||
val time = calendar.time | ||
val minecraftHours = SimpleDateFormat("HH").format(time) | ||
val minecraftMinutes = (SimpleDateFormat("mm").format(time).toLong() * 100) / 60 | ||
return "${minecraftHours}${minecraftMinutes}0".toLong() | ||
} | ||
} |