Skip to content

Commit

Permalink
add adjustable base color
Browse files Browse the repository at this point in the history
  • Loading branch information
U5B committed Apr 26, 2023
1 parent 35504dc commit 848b380
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/main/kotlin/net/usbwire/base/config/VigilanceConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ object VigilanceConfig : Vigilant(File(configFile)) {
var healthForcedHitbox = false


@Property(type = PropertyType.COLOR, name = "Base Health Color", description = "By default, white does not show hitbox. Change the color here to make hitboxes show.", category = "GlowHealth")
var healthBaseColor = Color.WHITE

@Property(type = PropertyType.COLOR, name = "Good Health Color", description = "", category = "GlowHealth")
var healthGoodColor = Color.GREEN
@Property(type = PropertyType.PERCENT_SLIDER, name = "Good Health Percentage", description = "", category = "GlowHealth")
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/net/usbwire/base/util/Hitbox.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object Hitbox {
val red = color.red / 255.0F
val green = color.green / 255.0F
val blue = color.blue / 255.0F
val alpha = 1.toFloat()
val alpha = color.alpha / 255.0F
WorldRenderer.drawBox(matrices, vertices, box, red, green, blue, alpha)
return true
}
Expand All @@ -36,14 +36,14 @@ object Hitbox {
val maxHealth = entity.maxHealth
val percentHealth = health / maxHealth
if (percentHealth >= VigilanceConfig.healthGoodPercent) {
return Color.WHITE
return VigilanceConfig.healthBaseColor
} else if (percentHealth >= VigilanceConfig.healthLowPercent && percentHealth <= VigilanceConfig.healthGoodPercent) {
return VigilanceConfig.healthGoodColor
} else if (percentHealth >= VigilanceConfig.healthCriticalPercent && percentHealth <= VigilanceConfig.healthLowPercent) {
return VigilanceConfig.healthLowColor
} else if (percentHealth <= VigilanceConfig.healthCriticalPercent) { // assuming its red
return VigilanceConfig.healthCriticalColor
}
return Color.WHITE
return VigilanceConfig.healthBaseColor // fallback if something went wrong!
}
}

0 comments on commit 848b380

Please sign in to comment.