aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-08-02 13:20:38 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-08-02 13:20:38 +0200
commit6ad284e2ea1e0692769cd6a8461cdff285a7b111 (patch)
tree6d3c8ea2c3f2a6016c35e86541b81836386be2f0 /src
parent2d7b3849f8a5476080f90e6c1697023166793907 (diff)
downloadskyhanni-6ad284e2ea1e0692769cd6a8461cdff285a7b111.tar.gz
skyhanni-6ad284e2ea1e0692769cd6a8461cdff285a7b111.tar.bz2
skyhanni-6ad284e2ea1e0692769cd6a8461cdff285a7b111.zip
King Talisman Helper
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Storage.java15
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java17
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt148
4 files changed, 180 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 75fe70e48..97ea42e45 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -43,6 +43,7 @@ import at.hannibal2.skyhanni.features.inventory.*
import at.hannibal2.skyhanni.features.itemabilities.FireVeilWandParticles
import at.hannibal2.skyhanni.features.itemabilities.abilitycooldown.ItemAbilityCooldown
import at.hannibal2.skyhanni.features.mining.HighlightMiningCommissionMobs
+import at.hannibal2.skyhanni.features.mining.KingTalismanHelper
import at.hannibal2.skyhanni.features.minion.MinionCollectLogic
import at.hannibal2.skyhanni.features.minion.MinionFeatures
import at.hannibal2.skyhanni.features.misc.*
@@ -365,6 +366,7 @@ class SkyHanniMod {
loadModule(RiftWiltedBerberisHelper())
loadModule(RiftHorsezookaHider())
loadModule(GriffinPetWarning())
+ loadModule(KingTalismanHelper())
//
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
index 1236d4313..f6116a343 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
@@ -13,7 +13,11 @@ import at.hannibal2.skyhanni.utils.LorenzVec;
import com.google.gson.annotations.Expose;
import net.minecraft.item.ItemStack;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
public class Storage {
@@ -345,5 +349,14 @@ public class Storage {
'}';
}
}
+
+ @Expose
+ public MiningConfig mining = new MiningConfig();
+
+ public static class MiningConfig {
+
+ @Expose
+ public List<String> kingsTalkedTo = new ArrayList<>();
+ }
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java
index 07f7c249a..83fb12977 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java
@@ -2,7 +2,15 @@ package at.hannibal2.skyhanni.config.features;
import at.hannibal2.skyhanni.config.core.config.Position;
import com.google.gson.annotations.Expose;
-import io.github.moulberry.moulconfig.annotations.*;
+import io.github.moulberry.moulconfig.annotations.Accordion;
+import io.github.moulberry.moulconfig.annotations.ConfigAccordionId;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorText;
+import io.github.moulberry.moulconfig.annotations.ConfigOption;
import io.github.moulberry.moulconfig.observer.Property;
import org.lwjgl.input.Keyboard;
@@ -592,6 +600,13 @@ public class MiscConfig {
@ConfigEditorBoolean
public boolean highlightCommissionMobs = false;
+ @Expose
+ @ConfigOption(name = "King Talisman Helper", desc = "Show kings you have not talked to yet, and when the next missing king will appear.")
+ @ConfigEditorBoolean
+ public boolean kingTalismanHelper = false;
+
+ @Expose
+ public Position kingTalismanHelperPos = new Position(-400, 220, false, true);
}
@Expose
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt
new file mode 100644
index 000000000..fde64d258
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt
@@ -0,0 +1,148 @@
+package at.hannibal2.skyhanni.features.mining
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.IslandType
+import at.hannibal2.skyhanni.data.ProfileStorageData
+import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.InventoryOpenEvent
+import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
+import at.hannibal2.skyhanni.utils.LorenzUtils.sorted
+import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc
+import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
+import at.hannibal2.skyhanni.utils.TimeUtils
+import io.github.moulberry.notenoughupdates.util.SkyBlockTime
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.util.*
+
+class KingTalismanHelper {
+ private val config get() = SkyHanniMod.feature.misc.mining
+
+ private val kingLocation = LorenzVec(129.6, 196.5, 194.1)
+ private val kingCircles = listOf(
+ "Brammor",
+ "Emkam",
+ "Redros",
+ "Erren",
+ "Thormyr",
+ "Emmor",
+ "Grandan",
+ )
+
+ private var allKingsDisplay = emptyList<String>()
+ private var farDisplay = ""
+ private var display = emptyList<String>()
+
+ fun isNearby() = LorenzUtils.skyBlockArea == "Royal Palace" && kingLocation.distanceToPlayer() > 10
+
+ @SubscribeEvent
+ fun onTick(event: LorenzTickEvent) {
+ if (!event.isMod(20)) return
+
+ if (!isEnabled()) {
+ display = emptyList()
+ return
+ }
+
+ update()
+ display = if (!isNearby()) allKingsDisplay else Collections.singletonList(farDisplay)
+ }
+
+ fun isEnabled() = config.kingTalismanHelper && IslandType.DWARVEN_MINES.isInIsland()
+
+ @SubscribeEvent
+ fun onInventoryOpen(event: InventoryOpenEvent) {
+ if (event.inventoryName != "Commissions") return
+ if (!isEnabled()) return
+ if (!isNearby()) return
+ val profileSpecific = ProfileStorageData.profileSpecific ?: return
+
+ val currentKing = getCurrentKing()
+ val kingsTalkedTo = profileSpecific.mining.kingsTalkedTo
+ if (currentKing !in kingsTalkedTo) {
+ LorenzUtils.debug("Found new king!")
+ kingsTalkedTo.add(currentKing)
+ update()
+ display = allKingsDisplay
+ }
+ }
+
+ private fun update() {
+ val profileSpecific = ProfileStorageData.profileSpecific ?: return
+ val kingsTalkedTo = profileSpecific.mining.kingsTalkedTo
+ if (kingsTalkedTo.size == kingCircles.size) {
+ allKingsDisplay = Collections.singletonList("§eAll Kings found.")
+ farDisplay = ""
+ return
+ }
+
+ allKingsDisplay = buildList {
+ var farDisplay_: String? = null
+
+ val currentKing = getCurrentKing()
+ for ((king, timeUntil) in getKingTimes()) {
+ val missing = king !in kingsTalkedTo
+ val missingString = if (missing) "" else " §aDone"
+
+ val current = king == currentKing
+
+ val missingTimeFormat = if (current) {
+ val time = TimeUtils.formatDuration(timeUntil - 1000 * 60 * 20 * (kingCircles.size - 1))
+ "§7(§b$time remaining§7)"
+ } else {
+ val time = TimeUtils.formatDuration(timeUntil, maxUnits = 2)
+ "§7(§bin $time§7)"
+ }
+
+
+ val currentString = if (current) "§6King " else ""
+ if (missing && current) {
+ farDisplay_ = "§cNext missing king: §7$king §eNow $missingTimeFormat"
+ }
+
+ val timeString = if (missing) " §cMissing " + missingTimeFormat else ""
+
+ add("§7$currentString$king$missingString$timeString")
+ }
+ farDisplay = farDisplay_ ?: nextMissingText()
+ }
+ }
+
+ private fun nextMissingText(): String {
+ val profileSpecific = ProfileStorageData.profileSpecific ?: error("profileSpecific is null")
+ val kingsTalkedTo = profileSpecific.mining.kingsTalkedTo
+ val (nextKing, until) = getKingTimes().filter { it.key !in kingsTalkedTo }.sorted().firstNotNullOf { it }
+ val time = TimeUtils.formatDuration(until, maxUnits = 2)
+
+ return "§cNext missing king: §7$nextKing §7(§bin $time§7)"
+ }
+
+ private fun getKingTimes(): MutableMap<String, Long> {
+ val oneSbDay = 1000 * 60 * 20
+ val oneCircleTime = oneSbDay * kingCircles.size
+ val kingTime = mutableMapOf<String, Long>()
+ for ((index, king) in kingCircles.withIndex()) {
+
+ val startTime = SkyBlockTime(day = index - 1)
+ var timeNext = startTime.toMillis()
+ while (timeNext < System.currentTimeMillis()) {
+ timeNext += oneCircleTime
+ }
+ val timeUntil = timeNext - System.currentTimeMillis()
+ kingTime[king] = timeUntil
+ }
+ return kingTime
+ }
+
+ private fun getCurrentKing() = getKingTimes().sortedDesc().firstNotNullOf { it.key }
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) {
+ if (!config.kingTalismanHelper) return
+
+ config.kingTalismanHelperPos.renderStrings(display, posLabel = "King Talisman Helper")
+ }
+}