diff options
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) |