From fe33e64b35d4ed8a049e5c1a85b4c7b0873b325b Mon Sep 17 00:00:00 2001 From: Brandon Date: Sat, 23 Sep 2023 07:25:19 -0300 Subject: Arachne fixes + timer #441 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix inconsistencies with arachne brood highlighting and add countdown… * Merge branch 'beta' into arachne-fixes * fixed merge conflicts --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 + .../skyhanni/config/features/CombatConfig.java | 10 +++++ .../skyhanni/features/mobs/MobHighlight.kt | 7 ++-- .../skyhanni/features/mobs/SpawnTimers.kt | 49 ++++++++++++++++++++++ 4 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/mobs/SpawnTimers.kt (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 4fbc113e6..88dc05924 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -72,6 +72,7 @@ import at.hannibal2.skyhanni.features.misc.update.UpdateManager import at.hannibal2.skyhanni.features.mobs.AreaMiniBossFeatures import at.hannibal2.skyhanni.features.mobs.AshfangMinisNametagHider import at.hannibal2.skyhanni.features.mobs.MobHighlight +import at.hannibal2.skyhanni.features.mobs.SpawnTimers import at.hannibal2.skyhanni.features.nether.ashfang.* import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper import at.hannibal2.skyhanni.features.rift.RiftAPI @@ -235,6 +236,7 @@ class SkyHanniMod { loadModule(SummoningMobManager()) loadModule(AreaMiniBossFeatures()) loadModule(MobHighlight()) + loadModule(SpawnTimers()) loadModule(MarkedPlayerManager()) loadModule(SlayerMiniBossFeatures()) loadModule(PlayerDeathMessages()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/CombatConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/CombatConfig.java index ad4240504..bd162396a 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/CombatConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/CombatConfig.java @@ -582,6 +582,16 @@ public class CombatConfig { @FeatureToggle public boolean areaBossRespawnTimer = false; + @Expose + @ConfigOption( + name = "Arachne Spawn Timer", + desc = "Show a timer when Arachne fragments or crystals are placed to indicate how long " + + "until the boss will spawn. §cTimer may be 1-2 seconds off." + ) + @ConfigEditorBoolean + @FeatureToggle + public boolean showArachneSpawnTimer = true; + @Expose @ConfigOption(name = "Enderman TP Hider", desc = "Stops the Enderman Teleportation animation.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/features/mobs/MobHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/mobs/MobHighlight.kt index a366f5ce5..cbe1bae37 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mobs/MobHighlight.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mobs/MobHighlight.kt @@ -41,7 +41,7 @@ class MobHighlight { val entity = event.entity val maxHealth = event.maxHealth if (config.arachneKeeperHighlight) { - if (maxHealth == 3_000 && entity is EntityCaveSpider) { + if ((maxHealth == 3_000 || maxHealth == 12_000) && entity is EntityCaveSpider) { RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.DARK_BLUE.toColor().withAlpha(127)) { config.arachneKeeperHighlight } RenderLivingEntityHelper.setNoHurtTime(entity) { config.arachneKeeperHighlight } @@ -88,10 +88,9 @@ class MobHighlight { !entity.hasNameTagWith(1, "[§7Lv500§8] §lArachne") ) return - val maxHealth = entity.baseMaxHealth - if (maxHealth == 12 || maxHealth == 4000) { + if (entity is EntityCaveSpider) { markArachneMinis(entity) - } else { + } else if (entity.baseMaxHealth == 20_000 || entity.baseMaxHealth == 100_000) { markArachne(entity) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/mobs/SpawnTimers.kt b/src/main/java/at/hannibal2/skyhanni/features/mobs/SpawnTimers.kt new file mode 100644 index 000000000..b2d76824d --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/mobs/SpawnTimers.kt @@ -0,0 +1,49 @@ +package at.hannibal2.skyhanni.features.mobs + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.TimeUtils.format +import net.minecraftforge.client.event.RenderWorldLastEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds + +class SpawnTimers { + private val config get() = SkyHanniMod.feature.combat.mobs + + private val arachneAltarLocation = LorenzVec(-283f, 51f, -179f) + private var arachneSpawnTime = SimpleTimeMark.farPast() + private val arachneFragmentMessage = "^☄ [a-z0-9_]{2,22} placed an arachne's calling! something is awakening! \\(4/4\\)\$".toRegex() + private val arachneCrystalMessage = "^☄ [a-z0-9_]{2,22} placed an arachne crystal! something is awakening!$".toRegex() + + @SubscribeEvent + fun onRenderWorld(event: RenderWorldLastEvent) { + if (!isEnabled()) return + if (arachneSpawnTime.isInPast()) return + val countDown = arachneSpawnTime.timeUntil() + + val format = countDown.format(showMilliSeconds = true) + event.drawDynamicText(arachneAltarLocation, "§b$format", 1.5) + } + + @SubscribeEvent + fun onChatReceived(event: LorenzChatEvent) { + if (!isEnabled()) return + val message = event.message.removeColor().lowercase() + + if (arachneFragmentMessage.matches(message) || arachneCrystalMessage.matches(message)) { + arachneSpawnTime = if (arachneCrystalMessage.matches(message)) + SimpleTimeMark.now() + 24.seconds + else + SimpleTimeMark.now() + 19.seconds + } + } + + fun isEnabled() = IslandType.SPIDER_DEN.isInIsland() && LorenzUtils.skyBlockArea == "Arachne's Sanctuary" && config.showArachneSpawnTimer +} \ No newline at end of file -- cgit