aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-12-04 12:48:49 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-12-04 12:48:49 +0100
commitf61770ac53e7599b31433536a6313dd94d438e71 (patch)
tree21129d60c6b6b638ba647659b6f9c7f94927aff9 /src/main/java
parenta8c3cc7979b35ca4061864dfa4e53a503a789042 (diff)
downloadskyhanni-f61770ac53e7599b31433536a6313dd94d438e71.tar.gz
skyhanni-f61770ac53e7599b31433536a6313dd94d438e71.tar.bz2
skyhanni-f61770ac53e7599b31433536a6313dd94d438e71.zip
Mark the background difficulty gray for unknown goals.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt35
2 files changed, 22 insertions, 19 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt
index 951638df6..84c7c21f3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt
@@ -29,4 +29,10 @@ object BingoAPI {
fun getCommunityTip(itemName: String) =
tips.filter { itemName.startsWith(it.key.split(" (Community Goal)")[0]) }.values.firstOrNull()
+ fun BingoGoal.getTip(): BingoJson.BingoTip? = if (type == GoalType.COMMUNITY) {
+ getCommunityTip(displayName)
+ } else {
+ tips[displayName]
+ }
+
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt
index f08b2be2f..672dce98c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt
@@ -1,15 +1,15 @@
package at.hannibal2.skyhanni.features.bingo
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.data.jsonobjects.repo.BingoJson.BingoTip
import at.hannibal2.skyhanni.events.GuiContainerEvent
+import at.hannibal2.skyhanni.features.bingo.BingoAPI.getTip
+import at.hannibal2.skyhanni.features.bingo.card.GoalType
import at.hannibal2.skyhanni.utils.InventoryUtils
-import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.getOrNull
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
-import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.inventory.GuiContainer
import net.minecraft.inventory.ContainerChest
import net.minecraftforge.event.entity.player.ItemTooltipEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -22,20 +22,16 @@ class BingoCardTips {
if (!isEnabled()) return
if (InventoryUtils.openInventoryName() != "Bingo Card") return
- val itemName = event.itemStack?.name?.removeColor() ?: return
+ val gui = Minecraft.getMinecraft().currentScreen as? GuiContainer ?: return
+ val slot = gui.slotUnderMouse
+ val goal = BingoAPI.bingoGoals.firstOrNull { it.slot == slot.slotNumber } ?: return
val toolTip = event.toolTip
- val communityGoal = toolTip.getOrNull(1) == "§5§o§8Community Goal"
- val bingoTip: BingoTip = if (communityGoal) {
- BingoAPI.getCommunityTip(itemName) ?: return
- } else {
- BingoAPI.tips[itemName] ?: return
- }
+ val bingoTip = goal.getTip() ?: return
+ val communityGoal = goal.type == GoalType.COMMUNITY
- if (!communityGoal) {
- val difficulty = Difficulty.valueOf(bingoTip.difficulty.uppercase())
- toolTip[0] = toolTip[0] + " §7(" + difficulty.displayName + "§7)"
- }
+ val difficulty = Difficulty.valueOf(bingoTip.difficulty.uppercase())
+ toolTip[0] = toolTip[0] + " §7(" + difficulty.displayName + "§7) ${goal.done}"
var index = if (!communityGoal) {
toolTip.indexOf("§5§o§7Reward")
@@ -63,13 +59,14 @@ class BingoCardTips {
for (slot in chest.inventorySlots) {
if (slot == null) continue
- val goal = BingoAPI.personalGoals.firstOrNull { it.slot == slot.slotNumber } ?: continue
+ val goal = BingoAPI.bingoGoals.firstOrNull { it.slot == slot.slotNumber } ?: continue
if (config.hideDoneDifficulty && goal.done) continue
- BingoAPI.tips[goal.displayName]?.let {
+ val color = goal.getTip()?.let {
val difficulty = Difficulty.valueOf(it.difficulty.uppercase())
- slot highlight difficulty.color.addOpacity(120)
- }
+ difficulty.color
+ } ?: LorenzColor.GRAY
+ slot highlight color.addOpacity(120)
}
}