diff --git a/src/main/java/com/lambda/mixin/world/MixinWorld.java b/src/main/java/com/lambda/mixin/world/MixinWorld.java index 8889b15e3..1b9c9cafd 100644 --- a/src/main/java/com/lambda/mixin/world/MixinWorld.java +++ b/src/main/java/com/lambda/mixin/world/MixinWorld.java @@ -1,6 +1,7 @@ package com.lambda.mixin.world; import com.lambda.client.module.modules.misc.AntiWeather; +import com.lambda.client.module.modules.render.TimeWarp; import com.lambda.client.module.modules.render.NoRender; import net.minecraft.util.math.BlockPos; import net.minecraft.world.EnumSkyBlock; @@ -32,4 +33,10 @@ private void getRainStrengthHead(float delta, CallbackInfoReturnable cir) cir.setReturnValue(0.0f); } } + + @Inject(method = "getWorldTime", at = @At("HEAD"), cancellable = true) + public void onGetWorldTime(CallbackInfoReturnable cir) { + if (TimeWarp.INSTANCE.isEnabled()) + cir.setReturnValue(TimeWarp.INSTANCE.getUpdatedTime()); + } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/TimeWarp.kt b/src/main/kotlin/com/lambda/client/module/modules/render/TimeWarp.kt new file mode 100644 index 000000000..39877b349 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/module/modules/render/TimeWarp.kt @@ -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() + } +} \ No newline at end of file