diff options
author | Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> | 2024-04-17 15:46:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-17 15:46:19 +0200 |
commit | 2d93420195fbcde780372b1597a38ac4f960519a (patch) | |
tree | 5b81df5c80fbc40c2d24a1fb9779376eb9a732aa /src/main/java/at/hannibal2/skyhanni/data/mob | |
parent | a99499ab99aee3e827cd77de50ec07ab81c0baf5 (diff) | |
download | skyhanni-2d93420195fbcde780372b1597a38ac4f960519a.tar.gz skyhanni-2d93420195fbcde780372b1597a38ac4f960519a.tar.bz2 skyhanni-2d93420195fbcde780372b1597a38ac4f960519a.zip |
Feature: Highlight own Golden/Diamond Goblin (#1466)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data/mob')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt | 31 |
1 files changed, 30 insertions, 1 deletions
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 4eab5d881..d35d46759 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt @@ -3,7 +3,9 @@ package at.hannibal2.skyhanni.data.mob import at.hannibal2.skyhanni.data.mob.Mob.Type import at.hannibal2.skyhanni.data.mob.MobFilter.summonOwnerPattern import at.hannibal2.skyhanni.events.MobEvent +import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.utils.CollectionUtils.toSingletonListOrEmpty +import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.EntityUtils.canBeSeen import at.hannibal2.skyhanni.utils.EntityUtils.cleanName import at.hannibal2.skyhanni.utils.EntityUtils.isCorrupted @@ -16,6 +18,7 @@ import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand import net.minecraft.entity.monster.EntityZombie import net.minecraft.util.AxisAlignedBB +import java.awt.Color /** * Represents a Mob in Hypixel Skyblock. @@ -97,6 +100,23 @@ class Mob( fun isInvisible() = if (baseEntity !is EntityZombie) baseEntity.isInvisible else false + private var highlightColor: Color? = null + fun highlight(color: Color) { + highlightColor = color + internalHighlight() + } + + private fun internalHighlight() { + highlightColor?.let { + RenderLivingEntityHelper.setEntityColorWithNoHurtTime(baseEntity, it.withAlpha(127)) { true } + } + } + + private fun internalRemoveColor() { + if (highlightColor == null) return + RenderLivingEntityHelper.removeCustomRender(baseEntity) + } + val boundingBox: AxisAlignedBB get() = relativeBoundingBox?.offset(baseEntity.posX, baseEntity.posY, baseEntity.posZ) ?: baseEntity.entityBoundingBox @@ -135,7 +155,9 @@ class Mob( internal fun internalAddEntity(entity: EntityLivingBase) { if (baseEntity.entityId > entity.entityId) { extraEntitiesList.add(0, baseEntity) + internalRemoveColor() baseEntity = entity + internalHighlight() } else { extraEntitiesList.add(extraEntitiesList.lastIndex + 1, entity) } @@ -146,14 +168,21 @@ class Mob( internal fun internalAddEntity(entities: Collection<EntityLivingBase>) { val list = entities.drop(1).toMutableList().apply { add(baseEntity) } extraEntitiesList.addAll(0, list) + internalRemoveColor() baseEntity = entities.first() + internalHighlight() updateBoundingBox() removeExtraEntitiesFromChecking() MobData.entityToMob.putAll(entities.associateWith { this }) } internal fun internalUpdateOfEntity(entity: EntityLivingBase) = when (entity.entityId) { - baseEntity.entityId -> baseEntity = entity + baseEntity.entityId -> { + internalRemoveColor() + baseEntity = entity + internalHighlight() + } + armorStand?.entityId ?: Int.MIN_VALUE -> armorStand = entity as EntityArmorStand else -> { extraEntitiesList.remove(entity) |