Add a asTextColor() method to the Colors.kt enum class

This commit is contained in:
Username404-59 2021-06-24 14:14:27 +02:00
parent 34de53beee
commit 2a87787b21
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
2 changed files with 9 additions and 3 deletions

View File

@ -12,8 +12,9 @@ import fr.username404.snowygui.gui.feature.Macro
import fr.username404.snowygui.gui.feature.riskyCheats
import net.minecraft.client.gui.screens.Screen
import net.minecraft.network.chat.Component
import net.minecraft.network.chat.TextComponent
import net.minecraft.network.chat.TranslatableComponent
import java.util.*
import java.util.Optional
private const val confPrefix: String = "screen.snowy.config"
private val translationComponent = TranslatableComponent(confPrefix)
@ -58,7 +59,9 @@ val SnowyConfigScreen: Screen = object: Screen(translationComponent) {
.requireRestart()
.setSaveConsumer {
riskyCheats = it
}.setTooltip(Component.nullToEmpty("WARNING: Do not use this on servers or you might get banned.")).build()
}.setTooltip(TextComponent("WARNING: Do not use this on servers or you might get banned.").apply {
style = style.withColor(Colors.RED.asTextColor())
}).build()
).addEntry(startSubCategory(TranslatableComponent("$confPrefix.colors")).also { builder ->
builder.addAll(
ClickGui.clickBoxes.map { box ->

View File

@ -1,5 +1,7 @@
package fr.username404.snowygui.gui.feature
import net.minecraft.network.chat.TextColor
enum class Colors(val hexValue: Int) {
TRANSPARENT(-0x1),
BLACK(0x000000),
@ -10,5 +12,6 @@ enum class Colors(val hexValue: Int) {
RED(0x660000),
GREEN(0x00FF7F),
ORANGE(0xf18e33),
PURPLE(0xA97BFF)
PURPLE(0xA97BFF);
fun asTextColor(): TextColor = TextColor.fromRgb(hexValue)
}