From d13954de4de5d9a04380bb4105c13d7ae564255e Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:27:32 +0200 Subject: Feature: Starred Mob Highlight + Fels Highlight/Line (#1558) Co-authored-by: Cal Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/data') diff --git a/src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt b/src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt index 1d5827490..7e7e9f96c 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt @@ -115,10 +115,17 @@ class Mob( private var highlightColor: Color? = null - /** If no alpha is set or alpha is set to 255 it will set the alpha to 127 */ - fun highlight(color: Color) { - highlightColor = color.takeIf { it.alpha == 255 }?.addAlpha(127) ?: color - internalHighlight() + /** If [color] has no alpha or alpha is set to 255 it will set the alpha to 127 + * If [color] is set to null it removes a highlight*/ + fun highlight(color: Color?) { + if (color == highlightColor) return + if (color == null) { + internalRemoveColor() + highlightColor = null + } else { + highlightColor = color.takeIf { it.alpha == 255 }?.addAlpha(127) ?: color + internalHighlight() + } } private fun internalHighlight() { @@ -162,8 +169,10 @@ class Mob( } private fun makeRelativeBoundingBox() = - (baseEntity.entityBoundingBox.union(extraEntities.filter { it !is EntityArmorStand } - .mapNotNull { it.entityBoundingBox }))?.offset(-baseEntity.posX, -baseEntity.posY, -baseEntity.posZ) + (baseEntity.entityBoundingBox.union( + extraEntities.filter { it !is EntityArmorStand } + .mapNotNull { it.entityBoundingBox }, + ))?.offset(-baseEntity.posX, -baseEntity.posY, -baseEntity.posZ) fun fullEntityList() = baseEntity.toSingletonListOrEmpty() + -- cgit