diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-02-11 01:53:12 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-02-11 01:53:12 +0100 |
commit | ded258748604449fa3582af59549bfe07f203b42 (patch) | |
tree | d4ff47f2d03a90ec461133db153f822714499611 /src | |
parent | b15a9457bb3649bcc807013840c6f41afdf26369 (diff) | |
download | skyhanni-ded258748604449fa3582af59549bfe07f203b42.tar.gz skyhanni-ded258748604449fa3582af59549bfe07f203b42.tar.bz2 skyhanni-ded258748604449fa3582af59549bfe07f203b42.zip |
Make deathmites use the new color render logic.
Diffstat (limited to 'src')
-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 |