summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/gui
diff options
context:
space:
mode:
authorEmpa <42304516+ItsEmpa@users.noreply.github.com>2024-05-18 12:56:20 +0200
committerGitHub <noreply@github.com>2024-05-18 12:56:20 +0200
commitf0aa9df4c216a0c9dedbd6bf186d17e3aa1717ed (patch)
treeacab9c69aa98f5cb2923f8dc62011275fa8d9096 /src/main/java/at/hannibal2/skyhanni/features/gui
parentdea8da66d4aa933b63df691d9db9d4eafc0a5e0e (diff)
downloadskyhanni-f0aa9df4c216a0c9dedbd6bf186d17e3aa1717ed.tar.gz
skyhanni-f0aa9df4c216a0c9dedbd6bf186d17e3aa1717ed.tar.bz2
skyhanni-f0aa9df4c216a0c9dedbd6bf186d17e3aa1717ed.zip
Fix: Quiver Warning (#1832)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/gui')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/gui/quiver/QuiverDisplay.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/gui/quiver/QuiverWarning.kt55
2 files changed, 43 insertions, 14 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/quiver/QuiverDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/quiver/QuiverDisplay.kt
index 608b66b2b..049cbc35c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/gui/quiver/QuiverDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/gui/quiver/QuiverDisplay.kt
@@ -64,7 +64,7 @@ class QuiverDisplay {
fun onQuiverUpdate(event: QuiverUpdateEvent) {
arrow = event.currentArrow
amount = event.currentAmount
- hideAmount = event.hideAmount
+ hideAmount = QuiverAPI.wearingSkeletonMasterChestplate
updateDisplay()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/quiver/QuiverWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/quiver/QuiverWarning.kt
index 59fd5e51d..40ef08c6a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/gui/quiver/QuiverWarning.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/gui/quiver/QuiverWarning.kt
@@ -2,15 +2,24 @@ package at.hannibal2.skyhanni.features.gui.quiver
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
+import at.hannibal2.skyhanni.data.ArrowType
+import at.hannibal2.skyhanni.data.QuiverAPI
+import at.hannibal2.skyhanni.data.QuiverAPI.amount
import at.hannibal2.skyhanni.data.TitleManager
import at.hannibal2.skyhanni.events.DungeonCompleteEvent
import at.hannibal2.skyhanni.events.KuudraCompleteEvent
+import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.QuiverUpdateEvent
import at.hannibal2.skyhanni.features.dungeon.DungeonAPI
+import at.hannibal2.skyhanni.features.nether.kuudra.KuudraAPI
import at.hannibal2.skyhanni.utils.ChatUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.DelayedRun
+import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarityOrNull
+import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import at.hannibal2.skyhanni.utils.SoundUtils
+import at.hannibal2.skyhanni.utils.StringUtils.createCommaSeparatedList
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.seconds
@@ -19,8 +28,7 @@ class QuiverWarning {
private val config get() = SkyHanniMod.feature.combat.quiverConfig
private var lastLowQuiverReminder = SimpleTimeMark.farPast()
- private var lowDuringInstance = false
- private var amount = 0
+ private var arrowsInInstance = mutableSetOf<ArrowType>()
@SubscribeEvent
fun onDungeonComplete(event: DungeonCompleteEvent) {
@@ -33,15 +41,28 @@ class QuiverWarning {
}
private fun onInstanceComplete() {
- if (!lowDuringInstance) return
- lowDuringInstance = false
+ val arrows = arrowsInInstance
+ arrowsInInstance.clear()
+ arrows.filter { it.amount <= config.lowQuiverAmount }
- if (config.reminderAfterRun) {
- lowQuiverAlert()
+ if (arrows.isNotEmpty() && config.reminderAfterRun) {
+ DelayedRun.runNextTick {
+ instanceAlert(arrows)
+ }
}
}
- private fun lowQuiverAlert() {
+ private fun instanceAlert(arrows: Set<ArrowType>) {
+ val arrowsText = arrows.map { arrowType ->
+ val rarity = arrowType.internalName.getItemStackOrNull()?.getItemRarityOrNull()?.chatColorCode ?: "§f"
+ "$rarity${arrowType.arrow}"
+ }.createCommaSeparatedList()
+ TitleManager.sendTitle("§cLow on arrows!", 5.seconds, 3.6, 7f)
+ ChatUtils.chat("Low on $arrowsText!")
+ SoundUtils.repeatSound(100, 30, SoundUtils.plingSound)
+ }
+
+ private fun lowQuiverAlert(amount: Int) {
if (lastLowQuiverReminder.passedSince() < 30.seconds) return
lastLowQuiverReminder = SimpleTimeMark.now()
TitleManager.sendTitle("§cLow on arrows!", 5.seconds, 3.6, 7f)
@@ -50,18 +71,26 @@ class QuiverWarning {
@SubscribeEvent
fun onQuiverUpdate(event: QuiverUpdateEvent) {
- amount = event.currentAmount
+ val amount = event.currentAmount
+ val arrow = event.currentArrow ?: return
+ if (arrow == QuiverAPI.NONE_ARROW_TYPE) return
+
+ if (inInstance()) arrowsInInstance.add(arrow)
if (amount > config.lowQuiverAmount) return
- if (DungeonAPI.inDungeon() || LorenzUtils.inKuudraFight) {
- lowDuringInstance = true
- }
if (config.lowQuiverNotification) {
- lowQuiverAlert()
+ lowQuiverAlert(amount)
}
}
@SubscribeEvent
+ fun onWorldSwitch(event: LorenzWorldChangeEvent) {
+ arrowsInInstance.clear()
+ }
+
+ private fun inInstance() = DungeonAPI.inDungeon() || KuudraAPI.inKuudra()
+
+ @SubscribeEvent
fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
event.move(35, "inventory.quiverAlert", "combat.quiverConfig.lowQuiverNotification")
}