Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.lambda.client.gui.hudgui.elements.player

import com.lambda.client.event.SafeClientEvent
import com.lambda.client.gui.hudgui.LabelHud
import com.lambda.client.util.color.ColorConverter
import com.lambda.client.util.text.RomanNumerals
import net.minecraft.potion.*
import net.minecraft.client.resources.I18n

internal object Effects : LabelHud(
name = "Effects",
category = Category.PLAYER,
description = "Displays active effects"
) {

private val romanNumerals by setting("Roman Numerals", true)
private val coloredEffectNames by setting("Colored Effect Names", true)

override fun SafeClientEvent.updateText() {
player.activePotionEffects.sortedBy { it.duration }.forEach {
val amplifier = if (romanNumerals) RomanNumerals.numberToRoman(it.amplifier + 1) else (it.amplifier + 1).toString()
val duration = Potion.getPotionDurationString(it, 1f)
val color = if (coloredEffectNames) ColorConverter.hexToRgb(it.potion.liquidColor) else secondaryColor
val name = I18n.format(it.potion.name)

displayText.add(name, color)
displayText.add(amplifier, primaryColor)
displayText.addLine("(${duration})", primaryColor)
}
}
}