From ded258748604449fa3582af59549bfe07f203b42 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 11 Feb 2023 01:53:12 +0100 Subject: Make deathmites use the new color render logic. --- .../features/dungeon/HighlightDungeonDeathmite.kt | 61 +++++----------------- 1 file changed, 13 insertions(+), 48 deletions(-) (limited to 'src/main/java') 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() - - @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() - .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 -- cgit