aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt53
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHighlightBlazes.kt85
2 files changed, 108 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()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHighlightBlazes.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHighlightBlazes.kt
new file mode 100644
index 000000000..274f0b3c9
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHighlightBlazes.kt
@@ -0,0 +1,85 @@
+package at.hannibal2.skyhanni.features.nether.ashfang
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.RenderMobColoredEvent
+import at.hannibal2.skyhanni.events.ResetEntityHurtTimeEvent
+import at.hannibal2.skyhanni.events.withAlpha
+import at.hannibal2.skyhanni.test.LorenzTest
+import at.hannibal2.skyhanni.utils.EntityUtils.getAllNameTagsWith
+import at.hannibal2.skyhanni.utils.LorenzColor
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import net.minecraft.client.Minecraft
+import net.minecraft.entity.item.EntityArmorStand
+import net.minecraft.entity.monster.EntityBlaze
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
+
+class AshfangHighlightBlazes {
+
+ private val blazes = mutableMapOf<EntityBlaze, LorenzColor>()
+
+ var nearAshfang = false
+ var tick = 0
+
+ @SubscribeEvent
+ fun onTick(event: TickEvent.ClientTickEvent) {
+ if (!isEnabled()) return
+
+ if (tick++ % 20 == 0) {
+ checkNearAshfang()
+ } else {
+ return
+ }
+
+ if (nearAshfang) {
+ for (entity in Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityBlaze>()
+ .filter { it !in blazes.keys }) {
+ val list = entity.getAllNameTagsWith(2, "Ashfang")
+ if (list.size == 1) {
+ val armorStand = list[0]
+ if (armorStand.name.contains("Ashfang Follower")) {
+ blazes[entity] = LorenzColor.DARK_GRAY
+ } else if (armorStand.name.contains("Ashfang Underling")) {
+ blazes[entity] = LorenzColor.RED
+ } else if (armorStand.name.contains("Ashfang Acolyte")) {
+ blazes[entity] = LorenzColor.BLUE
+ }
+ } else if (list.size > 1) {
+ println("found " + list.size + " name tags")
+ }
+ }
+ }
+
+ }
+
+ private fun checkNearAshfang() {
+ nearAshfang = Minecraft.getMinecraft().theWorld.loadedEntityList
+ .any { it is EntityArmorStand && it.name.contains("Ashfang") }
+ }
+
+ @SubscribeEvent
+ fun onRenderMobColored(event: RenderMobColoredEvent) {
+ if (!isEnabled()) return
+ val entity = event.entity
+ event.color = blazes[entity]?.toColor()?.withAlpha(LorenzTest.a.toInt()) ?: 0
+ }
+
+ @SubscribeEvent
+ fun onResetEntityHurtTime(event: ResetEntityHurtTimeEvent) {
+ if (!isEnabled()) return
+ val entity = event.entity
+ if (entity in blazes) {
+ event.shouldReset = true
+ }
+ }
+
+ @SubscribeEvent
+ fun onWorldChange(event: WorldEvent.Load) {
+ blazes.clear()
+ }
+
+ private fun isEnabled(): Boolean {
+ return LorenzUtils.inSkyblock && SkyHanniMod.feature.ashfang.highlightBlazes
+ }
+} \ No newline at end of file