From 202512d5f171754613f734b649aa24644b578d06 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Wed, 17 Apr 2024 15:20:19 +0200 Subject: Feature: Vermin Highlight (#1457) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 + .../area/westvillage/VerminHighlightConfig.java | 22 +++++++ .../rift/area/westvillage/WestVillageConfig.java | 7 ++- .../rift/area/westvillage/VerminHighlighter.kt | 70 ++++++++++++++++++++++ 4 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/VerminHighlightConfig.java create mode 100644 src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 0d4b18145..e682ee675 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -361,6 +361,7 @@ import at.hannibal2.skyhanni.features.rift.area.mirrorverse.RiftLavaMazeParkour import at.hannibal2.skyhanni.features.rift.area.mirrorverse.RiftUpsideDownParkour import at.hannibal2.skyhanni.features.rift.area.mirrorverse.TubulatorParkour import at.hannibal2.skyhanni.features.rift.area.stillgorechateau.RiftBloodEffigies +import at.hannibal2.skyhanni.features.rift.area.westvillage.VerminHighlighter import at.hannibal2.skyhanni.features.rift.area.westvillage.VerminTracker import at.hannibal2.skyhanni.features.rift.area.westvillage.kloon.KloonHacking import at.hannibal2.skyhanni.features.rift.area.wyldwoods.RiftLarva @@ -832,6 +833,7 @@ class SkyHanniMod { loadModule(SulphurSkitterBox()) loadModule(HighlightInquisitors()) loadModule(VerminTracker) + loadModule(VerminHighlighter()) loadModule(SkillProgress) loadModule(SkillTooltip()) loadModule(MaxPurseItems()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/VerminHighlightConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/VerminHighlightConfig.java new file mode 100644 index 000000000..23b785823 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/VerminHighlightConfig.java @@ -0,0 +1,22 @@ +package at.hannibal2.skyhanni.config.features.rift.area.westvillage; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import com.google.gson.annotations.Expose; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorColour; +import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; +import io.github.notenoughupdates.moulconfig.observer.Property; + +public class VerminHighlightConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Highlight Vermins in the West Village.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = true; + + @Expose + @ConfigOption(name = "Color", desc = "Change Vermin highlight color.") + @ConfigEditorColour + public Property color = Property.of("0:60:0:0:255"); +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/WestVillageConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/WestVillageConfig.java index f0e68cdde..5dbf1a231 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/WestVillageConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/westvillage/WestVillageConfig.java @@ -11,8 +11,13 @@ public class WestVillageConfig { @Expose public KloonHackingConfig hacking = new KloonHackingConfig(); - @ConfigOption(name = "Vermin Tracker", desc = "infested") + @ConfigOption(name = "Vermin Tracker", desc = "Track all vermins collected.") @Accordion @Expose public VerminTrackerConfig verminTracker = new VerminTrackerConfig(); + + @ConfigOption(name = "Vermin Highlighter", desc = "Highlight vermins.") + @Accordion + @Expose + public VerminHighlightConfig verminHighlight = new VerminHighlightConfig(); } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt new file mode 100644 index 000000000..f3d2e1a39 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt @@ -0,0 +1,70 @@ +package at.hannibal2.skyhanni.features.rift.area.westvillage + +import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor +import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha +import at.hannibal2.skyhanni.utils.ConditionalUtils +import at.hannibal2.skyhanni.utils.EntityUtils +import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName +import at.hannibal2.skyhanni.utils.TimeLimitedSet +import net.minecraft.entity.EntityLivingBase +import net.minecraft.entity.item.EntityArmorStand +import net.minecraft.entity.monster.EntitySilverfish +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.minutes + +class VerminHighlighter { + private val config get() = RiftAPI.config.area.westVillage.verminHighlight + + private val checkedEntites = TimeLimitedSet(1.minutes) + + // TODO repo + private val fly = + "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTMwYWMxZjljNjQ5Yzk5Y2Q2MGU0YmZhNTMzNmNjMTg1MGYyNzNlYWI5ZjViMGI3OTQwZDRkNGQ3ZGM4MjVkYyJ9fX0=" + private val spider = + "ewogICJ0aW1lc3RhbXAiIDogMTY1MDU1NjEzMTkxNywKICAicHJvZmlsZUlkIiA6ICI0ODI5MmJkMjI1OTc0YzUwOTZiMTZhNjEyOGFmMzY3NSIsCiAgInByb2ZpbGVOYW1lIiA6ICJLVVJPVE9ZVEIyOCIsCiAgInNpZ25hdHVyZVJlcXVpcmVkIiA6IHRydWUsCiAgInRleHR1cmVzIiA6IHsKICAgICJTS0lOIiA6IHsKICAgICAgInVybCIgOiAiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS84ZmRmNjJkNGUwM2NhNTk0YzhjZDIxZGQxNzUzMjdmMWNmNzdjNGJjMDU3YTA5NTk2MDNkODNhNjhiYTI3MDA4IgogICAgfQogIH0KfQ==" + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!isEnabled()) return + + for (entity in EntityUtils.getEntities()) { + val id = entity.entityId + if (checkedEntites.contains(id)) continue + checkedEntites.add(id) + + if (!isVermin(entity)) continue + val color = config.color.get().toChromaColor().withAlpha(60) + RenderLivingEntityHelper.setEntityColorWithNoHurtTime(entity, color) { isEnabled() } + } + } + + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + ConditionalUtils.onToggle(config.color) { + // running setEntityColorWithNoHurtTime() again + checkedEntites.clear() + } + } + + private fun isVermin(entity: EntityLivingBase): Boolean = when (entity) { + is EntityArmorStand -> entity.hasSkullTexture(fly) || entity.hasSkullTexture(spider) + is EntitySilverfish -> entity.baseMaxHealth == 8 + + else -> false + } + + private fun inArea() = LorenzUtils.skyBlockArea.let { it == "West Village" || it == "Infested House" } + + private fun hasItemInHand() = InventoryUtils.itemInHandId == "TURBOMAX_VACUUM".asInternalName() + + fun isEnabled() = RiftAPI.inRift() && inArea() && config.enabled && hasItemInHand() + +} -- cgit