Skip to content

Commit d2f21cd

Browse files
urFateAvanatiker
andauthoredApr 7, 2022
Add active potion effects HUD (#286)
* Add active potion effects HUD * Sort by ascending duration * Simplify comparator Co-authored-by: Constructor <fractalminds@protonmail.com>
1 parent 2a5fefd commit d2f21cd

File tree

1 file changed

+31
-0
lines changed
  • src/main/kotlin/com/lambda/client/gui/hudgui/elements/player

1 file changed

+31
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.lambda.client.gui.hudgui.elements.player
2+
3+
import com.lambda.client.event.SafeClientEvent
4+
import com.lambda.client.gui.hudgui.LabelHud
5+
import com.lambda.client.util.color.ColorConverter
6+
import com.lambda.client.util.text.RomanNumerals
7+
import net.minecraft.potion.*
8+
import net.minecraft.client.resources.I18n
9+
10+
internal object Effects : LabelHud(
11+
name = "Effects",
12+
category = Category.PLAYER,
13+
description = "Displays active effects"
14+
) {
15+
16+
private val romanNumerals by setting("Roman Numerals", true)
17+
private val coloredEffectNames by setting("Colored Effect Names", true)
18+
19+
override fun SafeClientEvent.updateText() {
20+
player.activePotionEffects.sortedBy { it.duration }.forEach {
21+
val amplifier = if (romanNumerals) RomanNumerals.numberToRoman(it.amplifier + 1) else (it.amplifier + 1).toString()
22+
val duration = Potion.getPotionDurationString(it, 1f)
23+
val color = if (coloredEffectNames) ColorConverter.hexToRgb(it.potion.liquidColor) else secondaryColor
24+
val name = I18n.format(it.potion.name)
25+
26+
displayText.add(name, color)
27+
displayText.add(amplifier, primaryColor)
28+
displayText.addLine("(${duration})", primaryColor)
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)
Please sign in to comment.