aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/slayer
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2022-09-24 19:46:16 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2022-09-24 19:46:16 +0200
commitf77519e200eaaba1fee7f06d9e5665f1c45b2032 (patch)
tree73c472e7372536c5a6ebdb5e325dbed9e0aa4c37 /src/main/java/at/hannibal2/skyhanni/features/slayer
parent9186bc695fafdfc8aad639d0ec400582ee5a66cb (diff)
downloadskyhanni-f77519e200eaaba1fee7f06d9e5665f1c45b2032.tar.gz
skyhanni-f77519e200eaaba1fee7f06d9e5665f1c45b2032.tar.bz2
skyhanni-f77519e200eaaba1fee7f06d9e5665f1c45b2032.zip
slayer quest warnings and slayer drops
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/slayer')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt174
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerType.kt48
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt36
3 files changed, 225 insertions, 33 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt
new file mode 100644
index 000000000..7711d6fe7
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt
@@ -0,0 +1,174 @@
+package at.hannibal2.skyhanni.features.slayer
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.ScoreboardData
+import at.hannibal2.skyhanni.data.SendTitleHelper
+import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.utils.LocationUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.matchRegex
+import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import at.hannibal2.skyhanni.utils.getLorenzVec
+import net.minecraft.entity.EntityLivingBase
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
+
+class SlayerQuestWarning {
+
+ private var needSlayerQuest = false
+ private var lastWarning = 0L
+ private var currentReason = ""
+ private var dirtySidebar = false
+ private var tick = 0
+ private var activeSlayer: SlayerType? = null
+
+ //TODO add check if player has clicked on an item, before mobs around you gets damage
+
+ @SubscribeEvent
+ fun onChatMessage(event: LorenzChatEvent) {
+ if (!isEnabled()) return
+
+ val message = event.message
+
+ //died
+ if (message == " §r§c§lSLAYER QUEST FAILED!") {
+ needNewQuest("The old slayer quest has failed!")
+ }
+ if (message == "§eYour unsuccessful quest has been cleared out!") {
+ needSlayerQuest = false
+ }
+
+ //no auto slayer
+ if (message.matchRegex(" §r§5§l» §r§7Talk to Maddox to claim your (.+) Slayer XP!")) {
+ needNewQuest("You have no Auto-Slayer active!")
+ }
+ if (message == " §r§a§lSLAYER QUEST COMPLETE!") {
+ needSlayerQuest = false
+ }
+
+ if (message == "§aYour Slayer Quest has been cancelled!") {
+ activeSlayer = null
+ }
+
+ //TODO hyp does no damage anymore
+
+ //TODO auto slayer disabled bc of no more money in bank or purse
+ }
+
+ private fun needNewQuest(reason: String) {
+ currentReason = reason
+ needSlayerQuest = true
+ }
+
+ @SubscribeEvent
+ fun onTick(event: TickEvent.ClientTickEvent) {
+ if (!isEnabled()) return
+
+ if (dirtySidebar) {
+ if (tick++ % 60 == 0) {
+ checkSidebar()
+ }
+ }
+ }
+
+ private fun checkSidebar() {
+ var loaded = false
+
+ var slayerQuest = false
+ var bossSlain = false
+ var slayBoss = false
+ var slayerTypeName = ""
+ var nextIsType = false
+ for (line in ScoreboardData.sidebarLinesFormatted()) {
+ if (nextIsType) {
+ slayerTypeName = line.removeColor()
+ nextIsType = false
+ }
+ if (line == "Slayer Quest") {
+ slayerQuest = true
+ nextIsType = true
+ }
+ if (line == "§aBoss slain!") {
+ bossSlain = true
+ }
+ if (line == "§eSlay the boss!") {
+ slayBoss = true
+ }
+ if (line == "§ewww.hypixel.net" || line == "§ewww.alpha.hypixel.net") {
+ loaded = true
+ }
+ }
+
+ activeSlayer = SlayerType.getByDisplayName(slayerTypeName)
+
+ if (loaded) {
+ dirtySidebar = false
+ if (slayerQuest && !needSlayerQuest) {
+ if (bossSlain) {
+ needNewQuest("You have no Auto-Slayer active!")
+ } else if (slayBoss) {
+ needNewQuest("You probably switched the server during an active boss and how hypixel doesn't know what to do.")
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onWorldChange(event: WorldEvent.Load) {
+ if (!SkyHanniMod.feature.slayer.questWarning) return
+
+ if (!needSlayerQuest) {
+ dirtySidebar = true
+ }
+ }
+
+ private fun tryWarn() {
+ if (!needSlayerQuest) return
+ warn("New Slayer Quest!", "Start a new slayer quest! $currentReason")
+ }
+
+ private fun warn(titleMessage: String, chatMessage: String) {
+ if (lastWarning + 10_000 > System.currentTimeMillis()) return
+
+ lastWarning = System.currentTimeMillis()
+ LorenzUtils.chat("§e[SkyHanni] $chatMessage")
+ SendTitleHelper.sendTitle("§e$titleMessage", 2_000)
+ }
+
+ @SubscribeEvent
+ fun onHealthUpdateEvent(event: EntityHealthUpdateEvent) {
+ if (!isEnabled()) return
+
+ val entity = event.entity
+ if (entity.getLorenzVec().distance(LocationUtils.playerLocation()) < 5) {
+ if (isSlayerMob(entity)) {
+ tryWarn()
+ }
+ }
+ }
+
+ private fun isSlayerMob(entity: EntityLivingBase): Boolean {
+ val area = LorenzUtils.skyBlockArea
+ val slayerType = SlayerType.getByArea(area) ?: return false
+
+ if (activeSlayer != null) {
+ val activeSlayer = activeSlayer!!
+ if (slayerType != activeSlayer) {
+ val activeSlayerName = activeSlayer.displayName
+ val slayerName = slayerType.displayName
+ warn(
+ "Wrong Slayer!",
+ "Wrong slayer selected! You have $activeSlayerName selected and are in the $slayerName area!"
+ )
+ }
+ }
+
+ return slayerType.clazz.isInstance(entity)
+ }
+
+ private fun isEnabled(): Boolean {
+ return LorenzUtils.inSkyblock && SkyHanniMod.feature.slayer.questWarning
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerType.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerType.kt
new file mode 100644
index 000000000..37a879106
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerType.kt
@@ -0,0 +1,48 @@
+package at.hannibal2.skyhanni.features.slayer
+
+import net.minecraft.entity.monster.EntityBlaze
+import net.minecraft.entity.monster.EntityEnderman
+import net.minecraft.entity.monster.EntitySpider
+import net.minecraft.entity.monster.EntityZombie
+import net.minecraft.entity.passive.EntityWolf
+
+enum class SlayerType(val displayName: String, val clazz: Class<*>) {
+ REVENANT("Revenant Horror", EntityZombie::class.java),
+ TARANTULA("Tarantula Broodfather", EntitySpider::class.java),
+ SVEN("Sven Packmaster", EntityWolf::class.java),
+ VOID("Voidgloom Seraph", EntityEnderman::class.java),
+ INFERNO("Inferno Demonlord", EntityBlaze::class.java),
+ ;
+
+ companion object {
+ fun getByArea(skyBlockArea: String): SlayerType? {
+ return when (skyBlockArea) {
+ "Graveyard",
+ "Coal Mine",
+ -> REVENANT
+
+ "Spiders Den",
+ -> TARANTULA
+
+ "Ruins",
+ "Howling Cave",
+ -> SVEN
+
+ "The End",
+ "Void Sepulture",
+ -> VOID
+
+ "Stronghold",
+ "The Wasteland",
+ "Smoldering Tomb",
+ -> INFERNO
+
+ else -> return null
+ }
+ }
+
+ fun getByDisplayName(text: String): SlayerType? {
+ return values().firstOrNull { text.startsWith(it.displayName) }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt
index a5b7ae229..c0b5101a2 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt
@@ -1,31 +1,24 @@
package at.hannibal2.skyhanni.features.slayer.blaze
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.config.core.util.render.TextRenderUtils
+import at.hannibal2.skyhanni.data.SendTitleHelper
import at.hannibal2.skyhanni.events.BossHealthChangeEvent
import at.hannibal2.skyhanni.features.damageindicator.BossType
import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.SoundUtils
import at.hannibal2.skyhanni.utils.SoundUtils.playSound
-import net.minecraft.client.Minecraft
-import net.minecraft.client.gui.ScaledResolution
-import net.minecraft.client.renderer.GlStateManager
-import net.minecraftforge.client.event.RenderGameOverlayEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
class BlazeSlayerFirePitsWarning {
companion object {
- private var textToRender = ""
private var lastFirePitsWarning = 0L
private var nextTickIn = 0
fun fireFirePits() {
- lastFirePitsWarning = System.currentTimeMillis()
- textToRender = "§cFire Pits!"
- nextTickIn = 0
+ SendTitleHelper.sendTitle("§cFire Pits!", 2_000)
}
}
@@ -36,9 +29,7 @@ class BlazeSlayerFirePitsWarning {
val difference = System.currentTimeMillis() - lastFirePitsWarning
if (difference > 0) {
- if (difference > 2_000) {
- textToRender = ""
- } else {
+ if (difference <= 2_000) {
if (nextTickIn++ % 10 == 0) {
if (SkyHanniMod.feature.slayer.firePitsWarning) {
SoundUtils.createSound("random.orb", 0.8f).playSound()
@@ -83,25 +74,4 @@ class BlazeSlayerFirePitsWarning {
BossType.SLAYER_BLAZE_TYPHOEUS_34,
)
}
-
- @SubscribeEvent
- fun renderOverlay(event: RenderGameOverlayEvent.Post) {
- if (event.type != RenderGameOverlayEvent.ElementType.ALL) return
- if (!isEnabled()) return
- if (!SkyHanniMod.feature.slayer.firePitsWarning) return
-
- val scaledResolution = ScaledResolution(Minecraft.getMinecraft())
- val width = scaledResolution.scaledWidth
- val height = scaledResolution.scaledHeight
-
- GlStateManager.enableBlend()
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0)
- val renderer = Minecraft.getMinecraft().fontRendererObj
-
- GlStateManager.pushMatrix()
- GlStateManager.translate((width / 2).toFloat(), (height / 1.8).toFloat(), 0.0f)
- GlStateManager.scale(4.0f, 4.0f, 4.0f)
- TextRenderUtils.drawStringCenteredScaledMaxWidth(textToRender, renderer, 0f, 0f, false, 75, 0)
- GlStateManager.popMatrix()
- }
} \ No newline at end of file