Skip to content

Commit

Permalink
Approximate formatted value based on substring for tooltip(s)
Browse files Browse the repository at this point in the history
  • Loading branch information
bibi-reden committed Jul 26, 2024
1 parent cf956ef commit 230a2f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import io.wispforest.owo.ui.container.FlowLayout
import io.wispforest.owo.ui.core.*
import net.minecraft.entity.attribute.EntityAttribute
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.text.Style
import net.minecraft.text.Text
import net.minecraft.util.Formatting

Expand Down Expand Up @@ -48,10 +49,12 @@ class AttributeComponent(private val attribute: EntityAttribute, private val pla
append(Text.translatable(childAttribute.translationKey).styled { it.withColor(Colors.SATURATED_BLUE) })
append(" (")
append(Text.literal(function.behavior.symbol).styled { it.withColor(Colors.DARK_GREEN) })
append(Text.literal("${function.value}:"))
append(Text.literal("${function.value}"))
append(Text.literal(":").fillStyle(Style.EMPTY.withColor(Colors.DARK_GRAY)))
append(Text.literal(formula.name.lowercase()).styled { it.withColor(if (formula == StackingFormula.Flat) Colors.SANDY else Colors.IMPISH_RED) })
append(")")
append(Text.literal(" (%.2f)\n".format(DataAttributesAPI.getValue(childAttribute, player).orElse(0.0))).formatted(Formatting.GRAY))
val decLength = function.value.toString().substringAfter('.').length
append(Text.literal(" (%.${decLength}f)\n".format(DataAttributesAPI.getValue(childAttribute, player).orElse(0.0))).formatted(Formatting.GRAY))
formatted(Formatting.ITALIC)
}
}
Expand Down
1 change: 1 addition & 0 deletions src/client/kotlin/com/bibireden/playerex/ui/util/Colors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.bibireden.playerex.ui.util

object Colors {
const val GRAY = 0x9C9C9C
const val DARK_GRAY = 0x5F5F5F
const val GOLD = 0xF0C25E
const val SATURATED_BLUE = 0x6EBAE5
const val SANDY = 0xEDCD76
Expand Down

0 comments on commit 230a2f5

Please sign in to comment.