Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add active potion effects HUD #286

Merged
merged 3 commits into from
Apr 7, 2022
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)
}
}
}