Skip to content

Commit a821ad1

Browse files
committed
Added colors to features and fixed attribute menu in 1.21.5. Release of beta 0.2.2
1 parent 0a2d515 commit a821ad1

File tree

10 files changed

+115
-37
lines changed

10 files changed

+115
-37
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Taken from Firmament
22
[versions]
3-
version = "Beta 0.2.0"
3+
version = "Beta 0.2.2"
44
minecraft = "1.21.5"
55
yarn_mappings="1.21.5+build.1"
66
loader_version="0.16.14"

src/main/kotlin/io/github/frostzie/skyfall/config/features/garden/GardenConfig.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.github.frostzie.skyfall.config.features.garden
22

33
import com.google.gson.annotations.Expose
4-
import io.github.notenoughupdates.moulconfig.ChromaColour
54
import io.github.notenoughupdates.moulconfig.annotations.Accordion
65
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean
76
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorColour
@@ -50,39 +49,42 @@ class GardenConfig {
5049
@ConfigEditorInfoText
5150
var infoText: String = ""
5251

53-
//TODO: Figure out how color system works since ChromaColour is saving hue to 0.0 constantly
54-
/*
5552
@Expose
5653
@ConfigOption(name = "Background Color", desc = "The background color.")
5754
@ConfigEditorColour
58-
var backgroundColor: String = "20:20:20:250:100"
55+
var backgroundColor: String = "0:250:13:13:13"
5956

6057
@Expose
6158
@ConfigOption(name = "Plot Color", desc = "The default color of plots.")
6259
@ConfigEditorColour
63-
var defaultPlotColor: String = "150:150:150:255:98"
60+
var defaultPlotColor: String = "0:255:211:211:211"
6461

6562
//TODO: add locked plot detection
6663
//@Expose
6764
//@ConfigOption(name = "Locked Plot Color", desc = "The color of the plot if it hasn't been unlocked.")
6865
//@ConfigEditorColour
69-
//var lockedPlotColor: String = "70:70:70:250:100"
66+
//var lockedPlotColor: String = "0:70:70:70:255"
7067

7168
@Expose
72-
@ConfigOption(name = "Text Color", desc = "Text, number and icon color")
69+
@ConfigOption(name = "Text Color", desc = "Visitor and total pest text color.")
7370
@ConfigEditorColour
74-
var textColor: String = "255:255:255:255:100"
71+
var textColor: String = "0:255:255:255:255"
72+
73+
@Expose
74+
@ConfigOption(name = "Plot Text", desc = "Plot Number color.")
75+
@ConfigEditorColour
76+
var plotTextColor: String = "0:255:0:0:0"
7577

7678
@Expose
7779
@ConfigOption(name = "Pest Plot Color", desc = "The color of the plot if it has a pest.")
7880
@ConfigEditorColour
79-
var pestColor: String = "253:220:92:255:100"
81+
var pestColor: String = "0:255:255:179:0"
8082

8183
@Expose
8284
@ConfigOption(name = "Sprayed Plot Color", desc = "The color of the plot if it has been sprayed.")
8385
@ConfigEditorColour
84-
var sprayColor: String = "178:255:255:255:100"
85-
*/
86+
var sprayColor: String = "0:255:0:249:255"
87+
8688

8789
@Expose
8890
@ConfigOption(name = "Player Icon", desc = "The type of icon that should be used for the player.")
@@ -96,11 +98,9 @@ class GardenConfig {
9698
override fun toString(): String = value
9799
}
98100

99-
/*
100101
@Expose
101102
@ConfigOption(name = "Player Icon Color", desc = "The color of the player icon if the cube is chosen.")
102103
@ConfigEditorColour
103-
var playerIconColor: String = "255:255:255:255:100"
104-
*/
104+
var playerIconColor: String = "0:150:255:0:112"
105105
}
106106
}

src/main/kotlin/io/github/frostzie/skyfall/config/features/inventory/InventoryConfig.kt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ package io.github.frostzie.skyfall.config.features.inventory
33
import com.google.gson.annotations.Expose
44
import io.github.notenoughupdates.moulconfig.annotations.Accordion
55
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean
6-
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDraggableList
6+
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorColour
77
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDropdown
88
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorKeybind
99
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption
1010
import org.lwjgl.glfw.GLFW
1111

1212
class InventoryConfig {
13-
//TODO: add a way to change the color of the highlight
1413
//TODO: remove green glass pane in Power Stone menu
1514
@Expose
1615
@Accordion
@@ -94,6 +93,11 @@ class InventoryConfig {
9493
@ConfigOption(name = "Hotkey", desc = "Pressing the keybind over the power stone will highlight it. Adds a toggle item in the top right corner to only show favorites.")
9594
@ConfigEditorKeybind(defaultKey = GLFW.GLFW_KEY_UNKNOWN)
9695
var favoriteKey: Int = GLFW.GLFW_KEY_UNKNOWN
96+
97+
@Expose
98+
@ConfigOption(name = "Color", desc = "The color of the favorite power stone.")
99+
@ConfigEditorColour
100+
var powerStoneColor: String = "0:220:255:170:0"
97101
}
98102

99103
@Expose
@@ -106,6 +110,11 @@ class InventoryConfig {
106110
@ConfigOption(name = "Hotkey", desc = "Pressing the keybind over a contact will highlight it. Adds a toggle item in the top right corner to only show favorites.")
107111
@ConfigEditorKeybind(defaultKey = GLFW.GLFW_KEY_UNKNOWN)
108112
var favoriteKey: Int = GLFW.GLFW_KEY_UNKNOWN
113+
114+
@Expose
115+
@ConfigOption(name = "Color", desc = "The color of the favorite abi contact.")
116+
@ConfigEditorColour
117+
var abiContactColor: String = "0:220:255:170:0"
109118
}
110119

111120
@Expose
@@ -123,5 +132,15 @@ class InventoryConfig {
123132
@ConfigOption(name = "Favorite Hotkey", desc = "Pressing the keybind over a pet will highlight it. Adds a toggle item in the top right corner to only show favorites.")
124133
@ConfigEditorKeybind(defaultKey = GLFW.GLFW_KEY_UNKNOWN)
125134
var favoriteKey: Int = GLFW.GLFW_KEY_UNKNOWN
135+
136+
@Expose
137+
@ConfigOption(name = "Color", desc = "The color of the favorite pets.")
138+
@ConfigEditorColour
139+
var petHighlightColor: String = "0:220:255:170:0"
140+
141+
@Expose
142+
@ConfigOption(name = "Color", desc = "The color of the active pet.")
143+
@ConfigEditorColour
144+
var petActiveColor: String = "0:220:0:255:0" //0, 255, 0, 220
126145
}
127146
}

src/main/kotlin/io/github/frostzie/skyfall/features/garden/map/GardenMap.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import io.github.frostzie.skyfall.features.IFeature
99
import io.github.frostzie.skyfall.hud.FeatureHudElement
1010
import io.github.frostzie.skyfall.hud.HudElementConfig
1111
import io.github.frostzie.skyfall.hud.HudManager
12+
import io.github.frostzie.skyfall.utils.ColorUtils
1213
import io.github.frostzie.skyfall.utils.IslandDetector
1314
import io.github.frostzie.skyfall.utils.garden.PestData
1415
import io.github.frostzie.skyfall.utils.garden.PestDetector
@@ -97,8 +98,8 @@ object GardenMap : IFeature {
9798

9899
val pestData = PestDetector.getPestData()
99100
val visitorData = VisitorUtils.getVisitorData()
100-
val backgroundColor = 0xFF0d0d0d.toInt()
101-
val headerTextColor = 0xffffff
101+
val backgroundColor = ColorUtils.parseColorString(config.backgroundColor)
102+
val headerTextColor = ColorUtils.parseColorString(config.textColor)
102103

103104
drawContext.fill(x, y, x + width, y + height, backgroundColor)
104105

@@ -152,9 +153,9 @@ object GardenMap : IFeature {
152153
sprayedPlots: List<GardenPlot>,
153154
textRenderer: TextRenderer
154155
) {
155-
val sprayedColor = 0xFF00f9ff.toInt()
156-
val pestColor = 0xFFffb300.toInt()
157-
val defaultColor = 0xD3D3D3BF.toInt()
156+
val sprayedColor = ColorUtils.parseColorString(config.sprayColor)
157+
val pestColor = ColorUtils.parseColorString(config.pestColor)
158+
val defaultColor = ColorUtils.parseColorString(config.defaultPlotColor)
158159

159160
for (row in 0 until gridCount) {
160161
for (col in 0 until gridCount) {
@@ -194,11 +195,11 @@ object GardenMap : IFeature {
194195
) {
195196
if (smallBoxSize < 12) return
196197
val numberText = "$plotNumber"
197-
val textColor = 0x000000.toInt()
198+
val plotTextColor = ColorUtils.parseColorString(config.plotTextColor)
198199
val textWidth = textRenderer.getWidth(numberText)
199200
val textX = x + smallBoxSize - textWidth - 2
200201
val textY = y + smallBoxSize - textRenderer.fontHeight - 2
201-
drawContext.drawText(textRenderer, numberText, textX, textY, textColor, false)
202+
drawContext.drawText(textRenderer, numberText, textX, textY, plotTextColor, false)
202203
}
203204

204205
private fun drawPlayerLocation(
@@ -240,7 +241,7 @@ object GardenMap : IFeature {
240241
)
241242
drawContext.matrices.pop()
242243
} else {
243-
val playerColor = 0xFFff000c.toInt()
244+
val playerColor = ColorUtils.parseColorString(config.playerIconColor)
244245
drawContext.fill(
245246
(pixelX - dotSize / 4),
246247
(pixelZ - dotSize / 4),

src/main/kotlin/io/github/frostzie/skyfall/features/inventory/FavoriteAbiContact.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.google.gson.reflect.TypeToken
55
import io.github.frostzie.skyfall.SkyFall
66
import io.github.frostzie.skyfall.features.Feature
77
import io.github.frostzie.skyfall.features.IFeature
8+
import io.github.frostzie.skyfall.utils.ColorUtils
89
import io.github.frostzie.skyfall.utils.KeyboardManager
910
import io.github.frostzie.skyfall.utils.LoggerProvider
1011
import io.github.frostzie.skyfall.utils.events.SlotClickEvent
@@ -37,6 +38,7 @@ object FavoriteAbiContact : IFeature {
3738
private var highlightedItems = mutableListOf<String>()
3839
private var favoredOnlyToggle = true
3940
private var currentScreen: HandledScreen<*>? = null
41+
private val configColor get() = SkyFall.feature.inventory.abiContact.abiContactColor
4042

4143
private val validSlotRanges = setOf(
4244
10..16,
@@ -254,7 +256,7 @@ object FavoriteAbiContact : IFeature {
254256

255257
val itemName = slot.stack.name.string
256258
if (highlightedItems.contains(itemName)) {
257-
context.fill(slot.x, slot.y, slot.x + 16, slot.y + 16, Color(255, 170, 0, 220).rgb)
259+
context.fill(slot.x, slot.y, slot.x + 16, slot.y + 16, ColorUtils.parseColorString(configColor))
258260
}
259261
}
260262

src/main/kotlin/io/github/frostzie/skyfall/features/inventory/FavoritePet.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.google.gson.reflect.TypeToken
55
import io.github.frostzie.skyfall.SkyFall
66
import io.github.frostzie.skyfall.features.Feature
77
import io.github.frostzie.skyfall.features.IFeature
8+
import io.github.frostzie.skyfall.utils.ColorUtils
89
import io.github.frostzie.skyfall.utils.KeyboardManager
910
import io.github.frostzie.skyfall.utils.LoggerProvider
1011
import io.github.frostzie.skyfall.utils.events.SlotClickEvent
@@ -47,8 +48,8 @@ object FavoritePet : IFeature {
4748
37..43
4849
)
4950

50-
private val FAVORITE_COLOR = Color(255, 170, 0, 220)
51-
private val ACTIVE_PET_COLOR = Color(0, 255, 0, 220)
51+
private val FAVORITE_COLOR get() = ColorUtils.parseColorString(SkyFall.feature.inventory.petMenu.petHighlightColor)
52+
private val ACTIVE_PET_COLOR get() = ColorUtils.parseColorString(SkyFall.feature.inventory.petMenu.petActiveColor)
5253

5354
init {
5455
loadConfig()
@@ -250,7 +251,7 @@ object FavoritePet : IFeature {
250251
}
251252
}
252253

253-
private fun getPetHighlightColor(itemStack: ItemStack, isFavorite: Boolean): Color? {
254+
private fun getPetHighlightColor(itemStack: ItemStack, isFavorite: Boolean): Int? {
254255
if (!PetUtils.isPet(itemStack)) {
255256
return null
256257
}
@@ -289,7 +290,7 @@ object FavoritePet : IFeature {
289290

290291
val highlightColor = getPetHighlightColor(slot.stack, isFavorite)
291292
if (highlightColor != null) {
292-
context.fill(slot.x, slot.y, slot.x + 16, slot.y + 16, highlightColor.rgb)
293+
context.fill(slot.x, slot.y, slot.x + 16, slot.y + 16, highlightColor)
293294
}
294295
}
295296

src/main/kotlin/io/github/frostzie/skyfall/features/inventory/FavoritePowerStone.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.google.gson.reflect.TypeToken
55
import io.github.frostzie.skyfall.SkyFall
66
import io.github.frostzie.skyfall.features.Feature
77
import io.github.frostzie.skyfall.features.IFeature
8+
import io.github.frostzie.skyfall.utils.ColorUtils
89
import io.github.frostzie.skyfall.utils.KeyboardManager
910
import io.github.frostzie.skyfall.utils.LoggerProvider
1011
import io.github.frostzie.skyfall.utils.events.SlotClickEvent
@@ -38,6 +39,7 @@ object FavoritePowerStone : IFeature {
3839
private val validSlotRanges = setOf(
3940
10..16, 19..25, 28..34, 37..43
4041
)
42+
private val configColor get() = SkyFall.feature.inventory.powerStone.powerStoneColor
4143

4244
init {
4345
loadConfig()
@@ -235,7 +237,7 @@ object FavoritePowerStone : IFeature {
235237
}
236238
val itemName = slot.stack.name.string
237239
if (highlightedItems.contains(itemName)) {
238-
context.fill(slot.x, slot.y, slot.x + 16, slot.y + 16, Color(255, 170, 0, 220).rgb)
240+
context.fill(slot.x, slot.y, slot.x + 16, slot.y + 16, ColorUtils.parseColorString(configColor))
239241
}
240242
}
241243

src/main/kotlin/io/github/frostzie/skyfall/features/inventory/attribute/AttributeMenu.kt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ object AttributeMenu : IFeature {
203203

204204
private fun cleanItemNameForMatching(itemName: String): String {
205205
return itemName
206-
.replace(Regex("\\s+X$"), "") // Remove " X" suffix for maxed items
206+
.replace(Regex("\\s+([IVXL]+)?$"), "")
207207
.trim()
208208
}
209209

@@ -294,10 +294,23 @@ object AttributeMenu : IFeature {
294294

295295
if (sourceLineIndex != -1) {
296296
val textRenderer = MinecraftClient.getInstance().textRenderer
297+
val prefix = ""
298+
val indent = " "
299+
val indentWidth = textRenderer.getWidth(indent)
300+
val availableWidth = MAX_LORE_WIDTH - indentWidth
301+
297302
val additionalLines = wayToObtainArray.flatMap { element ->
298-
val obtainText = "§7 • ${element.asString}"
299-
val wrappedOrderedLines = textRenderer.wrapLines(Text.literal(obtainText), MAX_LORE_WIDTH)
300-
wrappedOrderedLines.map { fromOrdered(it) }
303+
val obtainText = element.asString
304+
val wrappedText = textRenderer.wrapLines(Text.literal(obtainText), availableWidth)
305+
.map { fromOrdered(it) }
306+
307+
if (wrappedText.isEmpty()) {
308+
emptyList()
309+
} else {
310+
val firstLine = Text.literal("§7$prefix").append(wrappedText.first())
311+
val otherLines = wrappedText.drop(1).map { Text.literal("§7$indent").append(it) }
312+
listOf(firstLine) + otherLines
313+
}
301314
}
302315

303316
if (additionalLines.isNotEmpty()) {

src/main/kotlin/io/github/frostzie/skyfall/utils/ColorUtils.kt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ import net.minecraft.text.MutableText
55
import net.minecraft.text.Style
66
import net.minecraft.text.Text
77
import net.minecraft.text.TextColor
8+
import java.awt.Color
89

910
object ColorUtils {
11+
private val logger = LoggerProvider.getLogger("ColorUtils")
12+
1013
fun skyFallPrefixChat(): MutableText {
1114
val text = "SkyFall"
1215
val colors = listOf(
@@ -80,4 +83,41 @@ object ColorUtils {
8083
fun stripColorCodes(text: String): String {
8184
return text.replace("§[0-9a-fk-or]".toRegex(), "").trim()
8285
}
86+
87+
/**
88+
* Parses a color string from the config to an ARGB integer.
89+
* The format is assumed to be "chroma:alpha:red:green:blue".
90+
*/
91+
fun parseColorString(colorString: String): Int {
92+
try {
93+
val parts = colorString.split(":")
94+
if (parts.size < 5) return 0xFFFFFFFF.toInt()
95+
96+
val chroma = parts[0].toInt()
97+
val a = parts[1].toInt().coerceIn(0, 255)
98+
val r = parts[2].toInt().coerceIn(0, 255)
99+
val g = parts[3].toInt().coerceIn(0, 255)
100+
val b = parts[4].toInt().coerceIn(0, 255)
101+
102+
return if (chroma != 0) {
103+
val invertedChroma = (256 - chroma).coerceIn(1, 255)
104+
105+
val periodInMillis = (invertedChroma / 255.0) * 60000.0
106+
if (periodInMillis <= 0) {
107+
return (a shl 24) or (r shl 16) or (g shl 8) or b
108+
}
109+
110+
val hue = (System.currentTimeMillis() % periodInMillis.toLong()) / periodInMillis.toFloat()
111+
112+
val rainbowRgb = Color.HSBtoRGB(hue, 1.0f, 1.0f)
113+
(a shl 24) or (rainbowRgb and 0x00FFFFFF)
114+
} else {
115+
(a shl 24) or (r shl 16) or (g shl 8) or b
116+
}
117+
} catch (e: NumberFormatException) {
118+
logger.error("Failed to parse color string: $colorString", e)
119+
ChatUtils.error("Failed to parse color string: $colorString, report in the discord!")
120+
return 0xFFFFFFFF.toInt()
121+
}
122+
}
83123
}

src/main/resources/fabric.mod.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"schemaVersion": 1,
33
"id": "skyfall",
4-
"version": "0.2.0",
4+
"version": "0.2.2",
55
"name": "SkyFall",
66
"description": "QOL Hypixel Skyblock mod for newest versions of Minecraft",
77
"authors": [
@@ -12,7 +12,7 @@
1212
"sources": "https://github.com/Frostzie/SkyFall",
1313
"issues": "https://github.com/Frostzie/SkyFall/issues"
1414
},
15-
"license": "LGPL-3.0",
15+
"license": "LGPL-2.1",
1616
"icon": "assets/skyfall/icon.png",
1717
"environment": "client",
1818
"accessWidener": "skyfall.accesswidener",

0 commit comments

Comments
 (0)