From 3ccee1aa6f7c95f6f008caffa3ef593a017e1648 Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Fri, 14 May 2021 23:20:41 +0200 Subject: [PATCH] Start a major refactor, split the ClickButton.kt class into the ButtonInfo annotation and the ButtonImpl.kt class --- build.gradle.kts | 1 + common/build.gradle.kts | 1 + .../snowygui/mixins/RendererMixin.java | 4 +- .../fr/username404/snowygui/ClickGui.kt | 19 ++---- .../snowygui/config/ConfigScreen.kt | 10 +--- .../snowygui/config/Configuration.kt | 7 ++- .../fr/username404/snowygui/gui/Element.kt | 9 +-- .../snowygui/gui/elements/ClickBox.kt | 26 ++++----- .../ClickButton.kt => feature/ButtonImpl.kt} | 50 ++++++++-------- .../snowygui/gui/feature/ButtonInfo.kt | 25 ++++++++ .../username404/snowygui/gui/feature/Clock.kt | 26 +++++++++ .../snowygui/gui/feature/Colors.kt | 7 +++ .../snowygui/gui/feature/GammaBoost.kt | 16 +++++ .../snowygui/gui/feature/RiskyCheats.kt | 13 +++++ .../snowygui/misc/addComponents.kt | 58 ------------------- 15 files changed, 143 insertions(+), 129 deletions(-) rename common/src/main/kotlin/fr/username404/snowygui/gui/{elements/ClickButton.kt => feature/ButtonImpl.kt} (54%) create mode 100644 common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonInfo.kt create mode 100644 common/src/main/kotlin/fr/username404/snowygui/gui/feature/Clock.kt create mode 100644 common/src/main/kotlin/fr/username404/snowygui/gui/feature/Colors.kt create mode 100644 common/src/main/kotlin/fr/username404/snowygui/gui/feature/GammaBoost.kt create mode 100644 common/src/main/kotlin/fr/username404/snowygui/gui/feature/RiskyCheats.kt delete mode 100644 common/src/main/kotlin/fr/username404/snowygui/misc/addComponents.kt diff --git a/build.gradle.kts b/build.gradle.kts index cc12df6..2c5f038 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -104,6 +104,7 @@ allprojects { apply(plugin = "architectury-plugin") dependencies { implementation(kotlin("stdlib-jdk8", kotlinVer)) + implementation(kotlin("reflect", kotlinVer)) } tasks { withType(ShadowJar::class) { diff --git a/common/build.gradle.kts b/common/build.gradle.kts index d655510..1795a83 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,5 +1,6 @@ architectury { common(); injectInjectables = false } dependencies { modImplementation("net.fabricmc:fabric-loader:${rootProject.property("fabric_loader_version")}") + implementation(kotlin("reflect")) } diff --git a/common/src/main/java/fr/username404/snowygui/mixins/RendererMixin.java b/common/src/main/java/fr/username404/snowygui/mixins/RendererMixin.java index 66905cc..424dedb 100644 --- a/common/src/main/java/fr/username404/snowygui/mixins/RendererMixin.java +++ b/common/src/main/java/fr/username404/snowygui/mixins/RendererMixin.java @@ -1,7 +1,7 @@ package fr.username404.snowygui.mixins; import com.mojang.blaze3d.vertex.PoseStack; -import fr.username404.snowygui.misc.Storage; +import fr.username404.snowygui.gui.feature.NoHurtCamera; import net.minecraft.client.renderer.GameRenderer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -12,6 +12,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public class RendererMixin { @Inject(method = "bobHurt", at = @At("HEAD"), cancellable = true) private void onHurt(PoseStack poseStack, float f, CallbackInfo ci) { - if (!Storage.INSTANCE.getHurtCamera()) ci.cancel(); + if (NoHurtCamera.INSTANCE.getToggled()) ci.cancel(); } } diff --git a/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt b/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt index 182bdfa..0d89121 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt @@ -1,28 +1,18 @@ package fr.username404.snowygui +import fr.username404.snowygui.gui.ColoredElement import fr.username404.snowygui.gui.Element import fr.username404.snowygui.gui.SnowyScreen import fr.username404.snowygui.gui.elements.ClickBox -import fr.username404.snowygui.gui.elements.ClickButton -import fr.username404.snowygui.misc.Storage.addComponents -import net.minecraft.network.chat.TranslatableComponent - -private var baseXAxis: Double = 4.0 -internal fun newBox(translationKey: String, color: Int = 0x6C9E9D): ClickBox { - val result = ClickBox(baseXAxis, 4.0, name = TranslatableComponent(translationKey), color = color) - baseXAxis += 86 - return result -} object ClickGui: SnowyScreen() { private var GuiDragging: Boolean = false override val components = mutableSetOf() - internal fun addComps(vararg toAdd: Element) = components.addAll(toAdd) inline fun boxContext(args: ClickBox.() -> Unit) = components.filterIsInstance().forEach(args) - private inline fun buttonsContext(args: ClickButton.() -> Unit) = boxContext { buttons.values.forEach(args) } - override fun mouseClicked(d: Double, e: Double, i: Int): Boolean { buttonsContext { mouseClicked(d, e, i) }; return false } - override fun mouseReleased(d: Double, e: Double, i: Int): Boolean { buttonsContext { mouseReleased(d, e, i) }; return false } + private inline fun buttonsContext(args: ColoredElement.() -> Unit) = boxContext { buttons.forEach(args) } + override fun mouseClicked(d: Double, e: Double, i: Int): Boolean { buttonsContext { this.mouseClicked(d, e, i) }; return false } + override fun mouseReleased(d: Double, e: Double, i: Int): Boolean { buttonsContext { this.mouseReleased(d, e, i) }; return false } override fun mouseScrolled(d: Double, e: Double, f: Double): Boolean { boxContext { scroll(d, e, f) }; return false } override fun mouseDragged(d: Double, e: Double, i: Int, f: Double, g: Double): Boolean { if (i == 0) { @@ -36,5 +26,4 @@ object ClickGui: SnowyScreen() { } return super.mouseDragged(d, e, i, f, g) } - init { addComponents() } } \ No newline at end of file diff --git a/common/src/main/kotlin/fr/username404/snowygui/config/ConfigScreen.kt b/common/src/main/kotlin/fr/username404/snowygui/config/ConfigScreen.kt index 0d135b2..8d7d211 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/config/ConfigScreen.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/config/ConfigScreen.kt @@ -1,15 +1,11 @@ package fr.username404.snowygui.config import com.mojang.blaze3d.vertex.PoseStack -import fr.username404.snowygui.gui.Element -import fr.username404.snowygui.gui.SnowyScreen +import net.minecraft.client.gui.screens.Screen +import net.minecraft.network.chat.TranslatableComponent -open class SnowyConfigScreen: SnowyScreen("screen.snowygui.config") { // TODO Actual config screen +open class SnowyConfigScreen: Screen(TranslatableComponent("screen.snowygui.config")) { // TODO Actual config screen override fun render(poseStack: PoseStack?, i: Int, j: Int, f: Float) { renderBackground(poseStack) - super.render(poseStack, i, j, f) } - override val components: MutableSet = mutableSetOf( - // TODO Add components to the config gui - ) } \ No newline at end of file diff --git a/common/src/main/kotlin/fr/username404/snowygui/config/Configuration.kt b/common/src/main/kotlin/fr/username404/snowygui/config/Configuration.kt index 5de3e05..07147fe 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/config/Configuration.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/config/Configuration.kt @@ -5,7 +5,6 @@ import com.typesafe.config.ConfigException import com.typesafe.config.ConfigFactory.* import com.typesafe.config.ConfigRenderOptions import com.typesafe.config.ConfigValueFactory -import fr.username404.snowygui.ClickGui import fr.username404.snowygui.Snowy import io.github.config4k.extract import kotlinx.coroutines.coroutineScope @@ -70,13 +69,15 @@ object Configuration { Runtime.getRuntime().addShutdownHook( Thread { runBlocking { + /** ClickGui.boxContext { enabledFeatures.putAll( - buttons.map { button -> - button.key to button.value.toggled + this.buttons.map { + (it::class.java.getDeclaredField("name").get(this) as String) to (it::class.java.getDeclaredMethod("getToggled").invoke(it)) as Boolean // TODO Fix button configuration } ) } + **/ writeConfig(obtained.withValue("enabledFeatures", ConfigValueFactory.fromMap(enabledFeatures))).join() // TODO Fix formatting of enabledFeatures } } diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/Element.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/Element.kt index 73d943b..a4a0054 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/Element.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/Element.kt @@ -2,6 +2,8 @@ package fr.username404.snowygui.gui import com.mojang.blaze3d.vertex.* import fr.username404.snowygui.Snowy +import fr.username404.snowygui.gui.feature.Colors +import net.minecraft.client.gui.components.events.GuiEventListener import org.lwjgl.opengl.GL20 fun interface Renderable { @@ -25,7 +27,7 @@ fun interface Renderable { abstract class Element( @JvmField val xOrigin: Double, @JvmField val yOrigin: Double, val originalWidth: Int, val originalHeight: Int -): Renderable { +): Renderable, GuiEventListener { open var width = originalWidth; open var height = originalHeight open var x = xOrigin; open var y = yOrigin internal fun withinBounds(coordinateX: Double, coordinateY: Double, offsetWidth: Double = 0.0, offsetHeight: Double = 0.0): Boolean = @@ -55,18 +57,17 @@ abstract class Element( abstract class ColoredElement( x: Double, y: Double, width: Int, height: Int, - color: Int = TransparentColor, protected var opacity: Float, + color: Colors = Colors.TRANSPARENT, protected var opacity: Float, ) : Element(x, y, width, height) { open var color = color; protected set companion object { - const val TransparentColor: Int = -0x1 @JvmStatic protected fun VertexConsumer.colorIt(color: Int, opacity: Float = 1F): VertexConsumer { with(hextoRGB(color)) { return this@colorIt.color(get(0), get(1), get(2), opacity) } } } - internal fun VertexConsumer.colorEnd(color: Int = this@ColoredElement.color) = colorIt(color, opacity).endVertex() + internal fun VertexConsumer.colorEnd(color: Int = this@ColoredElement.color.hexValue) = colorIt(color, opacity).endVertex() } fun hextoRGB(hex: Int): MutableList { diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickBox.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickBox.kt index d6ba135..7ba22cb 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickBox.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickBox.kt @@ -7,27 +7,21 @@ import fr.username404.snowygui.gui.ColoredElement import fr.username404.snowygui.gui.Renderable.Rendering.buffer import fr.username404.snowygui.gui.Renderable.Rendering.defaultRectFunc import fr.username404.snowygui.gui.Renderable.Rendering.tessellator -import fr.username404.snowygui.gui.elements.ClickButton.Companion.Type +import fr.username404.snowygui.gui.feature.Colors import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import net.minecraft.client.Minecraft import net.minecraft.network.chat.TranslatableComponent +import org.jetbrains.annotations.ApiStatus import org.lwjgl.opengl.GL20 +@ApiStatus.Internal class ClickBox( - x: Double, y: Double, - color: Int = 0x6C9E9D, - private val name: TranslatableComponent? = null + x: Double = baseXAxis, y: Double, + color: Colors = Colors.BLUE, + val name: TranslatableComponent? = null ): ColoredElement(x, y, 80, 10, color, 0.5F) { - val buttons = mutableMapOf() // Can contain up to 16 buttons - fun addButtons(vararg collect: Pair Unit)?>, kind: Type = Type.TOGGLE): ClickBox { - buttons.putAll( - collect.map { - it.first to ClickButton(title = it.first, action = it.second, getColorFrom = this, kind = kind) - } - ) - return this - } + val buttons = mutableSetOf() @JvmField val buttonsProgressBar: ColoredElement = object: ColoredElement( (x + width), y + height + 3, @@ -59,6 +53,7 @@ class ClickBox( } companion object { + var baseXAxis: Double = 4.0; private set const val clickboxHeightOffset: Int = 80 private const val inclination: Double = 2.5 } @@ -95,7 +90,7 @@ class ClickBox( x = this@ClickBox.x + this@ClickBox.width - 3 y = this@ClickBox.y + this@ClickBox.height + 3 }.display(poseStack) - buttons.values.forEachIndexed { num, button -> + buttons.forEachIndexed { num, button -> val fullHeight = (y + height.toDouble())..(y + height + clickboxHeightOffset) button.also { it.x = x + 3 @@ -105,9 +100,10 @@ class ClickBox( } } else null if ((name != null) && (poseStack != null)) { - Minecraft.getInstance().font.draw(poseStack, name.string, x.toFloat() + 5, y.toFloat() + 1.5F, TransparentColor) + Minecraft.getInstance().font.draw(poseStack, name.string, x.toFloat() + 5, y.toFloat() + 1.5F, Colors.TRANSPARENT.hexValue) renderButtons?.join() } } } + init { baseXAxis += 86 } } \ No newline at end of file diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickButton.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonImpl.kt similarity index 54% rename from common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickButton.kt rename to common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonImpl.kt index 4aeee47..448b608 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickButton.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonImpl.kt @@ -1,29 +1,24 @@ -package fr.username404.snowygui.gui.elements +package fr.username404.snowygui.gui.feature import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack +import fr.username404.snowygui.ClickGui import fr.username404.snowygui.config.Configuration import fr.username404.snowygui.gui.ColoredElement import fr.username404.snowygui.gui.FontUtil import fr.username404.snowygui.gui.Renderable.Rendering.defaultRectFunc -import net.minecraft.client.gui.components.events.GuiEventListener +import fr.username404.snowygui.gui.elements.ClickBox +import fr.username404.snowygui.gui.feature.ButtonInfo.Companion.Type +import org.jetbrains.annotations.ApiStatus +import kotlin.reflect.full.findAnnotation -class ClickButton( - x: Double = 0.0, y: Double = 0.0, - width: Int = 73, height: Int = 8, getColorFrom: ColoredElement? = null, - private val kind: Type = Type.TOGGLE, - private val title: String = "", - private val action: (ClickButton.() -> Unit)? = null, -): ColoredElement(x, y, width, height, opacity = 0.60F), GuiEventListener { - override var color: Int = getColorFrom?.color ?: super.color - companion object { - enum class Type { - TOGGLE, - CLICK // TODO Fix the CLICK behaviour - } - internal var lightningFactor: Float = 0.33F - } - private fun execAction() { action?.invoke(this) } + +@ApiStatus.Internal +abstract class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) { + private val info = this::class.findAnnotation() ?: throw Exception("Missing @Button annotaton") + override var color: Colors = info.color + val title = this@ButtonImpl::class.simpleName + protected open fun execAction() = Unit private var wasWithinBounds: Boolean = false var toggled: Boolean = false; private set(value) { if (value) lightUp() else if (field) lightDown() @@ -32,11 +27,11 @@ class ClickButton( execAction() } else field = value } - private fun lightUp() { opacity += lightningFactor } - private fun lightDown() { opacity -= lightningFactor } + private fun lightUp() { opacity += ButtonInfo.lightningFactor } + private fun lightDown() { opacity -= ButtonInfo.lightningFactor } override fun mouseClicked(d: Double, e: Double, i: Int): Boolean { wasWithinBounds = withinBounds(d, e).also { - if (it && (kind == Type.TOGGLE)) { + if (it && (info.kind == Type.TOGGLE)) { toggled = !toggled } } @@ -44,7 +39,7 @@ class ClickButton( } override fun mouseReleased(d: Double, e: Double, i: Int): Boolean { - if (wasWithinBounds && (kind == Type.CLICK)) { + if (wasWithinBounds && (info.kind == Type.CLICK)) { toggled = true }; return false } @@ -54,15 +49,20 @@ class ClickButton( defaultRectFunc() RenderSystem.enableTexture() RenderSystem.disableBlend() - if (poseStack != null) { + if (poseStack != null && title != null) { FontUtil.drawScaled(poseStack, title, x + 1, y + 1, 0.75F) } } init { - if (kind == Type.TOGGLE) { + if (info.kind == Type.TOGGLE) { Configuration.enabledFeatures[title]?.let { toggled = it } } + ButtonInfo + ClickGui.components.filterIsInstance().find { + it.name!!.key == info.parent.translationKey + }?.buttons!!.add(this) } -} \ No newline at end of file +} + diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonInfo.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonInfo.kt new file mode 100644 index 0000000..6feded0 --- /dev/null +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonInfo.kt @@ -0,0 +1,25 @@ +package fr.username404.snowygui.gui.feature + +import fr.username404.snowygui.ClickGui +import fr.username404.snowygui.gui.elements.ClickBox +import net.minecraft.network.chat.TranslatableComponent + +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.RUNTIME) +annotation class ButtonInfo( + val parent: Category, + val kind: Type = Type.TOGGLE, + val color: Colors = Colors.BLUE +) { + companion object { + internal var lightningFactor: Float = 0.33F + enum class Type { + TOGGLE, + CLICK // TODO Fix the CLICK behaviour + } + } +}; enum class Category(val translationKey: String) { + MISC("snowy.clickbox.misc"), + RISKY("snowy.clickbox.risky"); + init { ClickGui.components.add(ClickBox(y = 0.0, name = TranslatableComponent(translationKey))) } +} \ No newline at end of file diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/Clock.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/Clock.kt new file mode 100644 index 0000000..f9954ea --- /dev/null +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/Clock.kt @@ -0,0 +1,26 @@ +package fr.username404.snowygui.gui.feature + +import com.mojang.blaze3d.vertex.PoseStack +import fr.username404.snowygui.Snowy.Companion.onEvent +import fr.username404.snowygui.gui.FontUtil +import kotlinx.datetime.TimeZone +import kotlinx.datetime.toLocalDateTime +import kotlinx.datetime.Clock as DatetimeClock + +@ButtonInfo(Category.MISC) +object Clock: ButtonImpl() { + private val currentTimezone = TimeZone.currentSystemDefault() + init { + onEvent("HudRender") { + if (toggled) { + with(DatetimeClock.System.now().toLocalDateTime(currentTimezone)) { + FontUtil.drawScaled(it.first() as PoseStack, + "$hour:$minute:${second.let { if (it >= 10) it else "0$it" }}", + 5.0, 5.0, + 0.85F, color = 0xe69500 + ) + } + } + } + } +} \ No newline at end of file diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/Colors.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/Colors.kt new file mode 100644 index 0000000..35b78b4 --- /dev/null +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/Colors.kt @@ -0,0 +1,7 @@ +package fr.username404.snowygui.gui.feature + +enum class Colors(val hexValue: Int) { + TRANSPARENT(-0x1), + BLUE(0x6C9E9D), + RED(0x660000); +} \ No newline at end of file diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/GammaBoost.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/GammaBoost.kt new file mode 100644 index 0000000..326ff18 --- /dev/null +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/GammaBoost.kt @@ -0,0 +1,16 @@ +package fr.username404.snowygui.gui.feature + +import net.minecraft.client.Minecraft + +@ButtonInfo(Category.MISC) +object GammaBoost: ButtonImpl() { + private var oldGamma = 0.0 + override fun execAction() { + with(Minecraft.getInstance().options) { + gamma = if (toggled) { + if (gamma < 1400.0) oldGamma = gamma + 1400.0 + } else oldGamma + } + } +} \ No newline at end of file diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/RiskyCheats.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/RiskyCheats.kt new file mode 100644 index 0000000..4327900 --- /dev/null +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/RiskyCheats.kt @@ -0,0 +1,13 @@ +package fr.username404.snowygui.gui.feature + +import net.minecraft.client.Minecraft + +@ButtonInfo(Category.RISKY, color = Colors.RED) +object NoHurtCamera: ButtonImpl() + +@ButtonInfo(Category.RISKY, color = Colors.RED) +object NoGravity: ButtonImpl() { + override fun execAction() { + Minecraft.getInstance().player?.isNoGravity = this.toggled + } +} \ No newline at end of file diff --git a/common/src/main/kotlin/fr/username404/snowygui/misc/addComponents.kt b/common/src/main/kotlin/fr/username404/snowygui/misc/addComponents.kt deleted file mode 100644 index 5b131b1..0000000 --- a/common/src/main/kotlin/fr/username404/snowygui/misc/addComponents.kt +++ /dev/null @@ -1,58 +0,0 @@ -package fr.username404.snowygui.misc - -import com.mojang.blaze3d.vertex.PoseStack -import fr.username404.snowygui.ClickGui -import fr.username404.snowygui.Snowy.Companion.onEvent -import fr.username404.snowygui.config.Configuration -import fr.username404.snowygui.gui.FontUtil -import fr.username404.snowygui.newBox -import io.github.config4k.getValue -import kotlinx.datetime.Clock -import kotlinx.datetime.TimeZone -import kotlinx.datetime.toLocalDateTime -import net.minecraft.client.Minecraft - -object Storage { - val currentTimezone = TimeZone.currentSystemDefault() - private var oldGamma = 0.0 - private const val redColor = 0x660000 - var clock: Boolean = false; private set - var hurtCamera: Boolean = true; private set - - private val riskyCheats: Boolean by Configuration.obtained - fun ClickGui.addComponents() { - addComps( - newBox("snowy.clickbox.misc").addButtons( - "GammaBoost" to { - with(Minecraft.getInstance().options) { - gamma = if (toggled) { - if (gamma < 1400.0) oldGamma = gamma - 1400.0 - } else oldGamma - } - }, "Clock" to { clock = toggled }, - ), - ) - if (riskyCheats) { - addComps( - newBox("snowy.clickbox.risky", color = redColor).addButtons( - "NoGravity" to { Minecraft.getInstance().player?.let { it.isNoGravity = toggled } }, - "NoHurtCamera" to { hurtCamera = !toggled }, - ) - ) - } - } - init { - onEvent("HudRender") { - if (clock) { - with(Clock.System.now().toLocalDateTime(currentTimezone)) { - FontUtil.drawScaled(it.first() as PoseStack, - "$hour:$minute:${second.let { if (it >= 10) it else "0$it" }}", - 5.0, 5.0, - 0.85F, color = 0xe69500 - ) - } - } - } - } -} \ No newline at end of file