Skip to content

Commit

Permalink
Feature: Vermin Highlight (#1457)
Browse files Browse the repository at this point in the history
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
  • Loading branch information
hannibal002 and hannibal002 authored Apr 17, 2024
1 parent bbb447e commit 202512d
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -832,6 +833,7 @@ class SkyHanniMod {
loadModule(SulphurSkitterBox())
loadModule(HighlightInquisitors())
loadModule(VerminTracker)
loadModule(VerminHighlighter())
loadModule(SkillProgress)
loadModule(SkillTooltip())
loadModule(MaxPurseItems())
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String> color = Property.of("0:60:0:0:255");
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Original file line number Diff line number Diff line change
@@ -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<Int>(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<EntityLivingBase>()) {
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()

}

0 comments on commit 202512d

Please sign in to comment.