aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt
diff options
context:
space:
mode:
authorLorenz <lo.scherf@gmail.com>2022-09-04 19:03:24 +0200
committerLorenz <lo.scherf@gmail.com>2022-09-04 19:03:24 +0200
commitb33102aa38f460da3f21708d9bb31f030c517cf7 (patch)
tree36deac1bd2ff2ea317b6f6e17205bf6c2192756d /src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt
parentf4e16cc1b3accc3c5ae71ffb42a0df83ed6ffc4b (diff)
downloadskyhanni-b33102aa38f460da3f21708d9bb31f030c517cf7.tar.gz
skyhanni-b33102aa38f460da3f21708d9bb31f030c517cf7.tar.bz2
skyhanni-b33102aa38f460da3f21708d9bb31f030c517cf7.zip
add highlight different ashfang blazes in their respective color
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt53
1 files changed, 23 insertions, 30 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt b/src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt
index 877db7e6a..74cf7847b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt
@@ -2,6 +2,9 @@ package at.hannibal2.skyhanni.features
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.RenderMobColoredEvent
+import at.hannibal2.skyhanni.events.ResetEntityHurtTimeEvent
+import at.hannibal2.skyhanni.events.withAlpha
import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
@@ -15,40 +18,12 @@ import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable
-import java.awt.Color
import java.util.regex.Pattern
class SummoningMobManager {
- companion object {
-
- @JvmStatic
- fun <T> setColorMultiplier(
- entity: T,
- lightBrightness: Float,
- partialTickTime: Float,
- cir: CallbackInfoReturnable<Int>,
- ) {
- if (SkyHanniMod.feature.abilities.summoningMobColored) {
- if (entity is EntityLiving && entity in summoningMobs.keys) {
- cir.returnValue = LorenzColor.GREEN.toColor().withAlpha(127)
- }
- }
- }
-
- @JvmStatic
- fun replaceHurtTime(entity: EntityLivingBase): Int {
- return if (SkyHanniMod.feature.abilities.summoningMobColored
- && entity in summoningMobs.keys
- ) 0 else entity.hurtTime
- }
-
- fun Color.withAlpha(alpha: Int): Int = (alpha.coerceIn(0, 255) shl 24) or (this.rgb and 0x00ffffff)
-
- private val summoningMobs = mutableMapOf<EntityLiving, SummoningMob>()
- }
+ private val summoningMobs = mutableMapOf<EntityLiving, SummoningMob>()
private val summoningMobNametags = mutableListOf<EntityArmorStand>()
private var summoningsSpawned = 0
private var searchArmorStands = false
@@ -174,7 +149,7 @@ class SummoningMobManager {
}
@SubscribeEvent
- fun renderOverlay(event: WorldEvent.Load) {
+ fun onWorldChange(event: WorldEvent.Load) {
despawned()
}
@@ -191,6 +166,24 @@ class SummoningMobManager {
event.isCanceled = entity in summoningMobNametags
}
+ @SubscribeEvent
+ fun onRenderMobColored(event: RenderMobColoredEvent) {
+ if (SkyHanniMod.feature.abilities.summoningMobColored) {
+ val entity = event.entity
+ if (entity is EntityLiving && entity in summoningMobs.keys) {
+ event.color = LorenzColor.GREEN.toColor().withAlpha(127)
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onResetEntityHurtTime(event: ResetEntityHurtTimeEvent) {
+ val entity = event.entity
+ if (SkyHanniMod.feature.abilities.summoningMobColored && entity in summoningMobs.keys) {
+ event.shouldReset = true
+ }
+ }
+
private fun despawned() {
summoningMobs.clear()
summoningMobNametags.clear()