diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/dungeon/HighlightDungeonDeathmite.kt | 61 |
1 files changed, 13 insertions, 48 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/HighlightDungeonDeathmite.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/HighlightDungeonDeathmite.kt index 1ce2e315b..27493abc4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/HighlightDungeonDeathmite.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/HighlightDungeonDeathmite.kt @@ -1,65 +1,30 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.RenderMobColoredEvent -import at.hannibal2.skyhanni.events.ResetEntityHurtEvent +import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent import at.hannibal2.skyhanni.events.withAlpha +import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth -import net.minecraft.client.Minecraft import net.minecraft.entity.monster.EntitySilverfish -import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class HighlightDungeonDeathmite { - private var tick = 0 - private val deathmites = mutableListOf<EntitySilverfish>() - - @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (!isEnabled()) return - - if (tick++ % 20 == 0) { - find() - } - } - @SubscribeEvent - fun onRenderMobColored(event: RenderMobColoredEvent) { - if (!isEnabled()) return - val entity = event.entity - - if (entity in deathmites) { - event.color = LorenzColor.DARK_RED.toColor().withAlpha(20) - } - } + fun onEntityHealthUpdate(event: EntityMaxHealthUpdateEvent) { + if (!LorenzUtils.inDungeons) return + if (!SkyHanniMod.feature.dungeon.highlightDeathmites) return - @SubscribeEvent - fun onResetEntityHurtTime(event: ResetEntityHurtEvent) { - if (!isEnabled()) return val entity = event.entity - - if (entity in deathmites) { - event.shouldReset = true + val maxHealth = event.maxHealth + + if (entity is EntitySilverfish) { + if (maxHealth == 1_000_000_000) { + RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.DARK_RED.toColor().withAlpha(20)) + { SkyHanniMod.feature.dungeon.highlightDeathmites } + RenderLivingEntityHelper.setNoHurtTime(entity) { SkyHanniMod.feature.dungeon.highlightDeathmites } + } } } - - @SubscribeEvent - fun onWorldChange(event: WorldEvent.Load) { - deathmites.clear() - } - - private fun find() { - Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntitySilverfish>() - .filter { it !in deathmites && it.baseMaxHealth >= 1_000_000_000 } - .forEach(deathmites::add) - } - - private fun isEnabled(): Boolean { - - return LorenzUtils.inDungeons && SkyHanniMod.feature.dungeon.highlightDeathmites - } }
\ No newline at end of file |