diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-02 20:21:10 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-02 20:21:10 +0100 |
commit | 76a1c7eb680cb31b050fb848a6a070d33df037c3 (patch) | |
tree | 97e5350baaf57974e7aded502b844f24d7ea7131 /src/main/java/at/hannibal2/skyhanni | |
parent | ebefae8ba16605304779618571485b07f91bb2f4 (diff) | |
download | skyhanni-76a1c7eb680cb31b050fb848a6a070d33df037c3.tar.gz skyhanni-76a1c7eb680cb31b050fb848a6a070d33df037c3.tar.bz2 skyhanni-76a1c7eb680cb31b050fb848a6a070d33df037c3.zip |
Added option to show king talisman helper outside Dwarven Mines. Fixed King Talisman Helper once again.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/MiningConfig.java | 32 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt | 56 |
2 files changed, 70 insertions, 18 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/MiningConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/MiningConfig.java index 840096cac..5272336df 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/MiningConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/MiningConfig.java @@ -92,19 +92,33 @@ public class MiningConfig { } @Expose - @ConfigOption(name = "Highlight Commission Mobs", desc = "Highlight Mobs that are part of active commissions.") - @ConfigEditorBoolean - @FeatureToggle - public boolean highlightCommissionMobs = false; + @ConfigOption(name = "King Talisman", desc = "") + @Accordion + public KingTalismanConfig kingTalisman = new KingTalismanConfig(); + + public static class KingTalismanConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Show kings you have not talked to yet, and when the next missing king will appear.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = false; + + @Expose + @ConfigOption(name = "Outside Mines", desc = "Show the display even while outside the Dwarven Mines.") + @ConfigEditorBoolean + @FeatureToggle + public boolean outsideMines = false; + + @Expose + public Position position = new Position(-400, 220, false, true); + } @Expose - @ConfigOption(name = "King Talisman Helper", desc = "Show kings you have not talked to yet, and when the next missing king will appear.") + @ConfigOption(name = "Highlight Commission Mobs", desc = "Highlight Mobs that are part of active commissions.") @ConfigEditorBoolean @FeatureToggle - public boolean kingTalismanHelper = false; - - @Expose - public Position kingTalismanHelperPos = new Position(-400, 220, false, true); + public boolean highlightCommissionMobs = false; @Expose @ConfigOption(name = "Names in Core", desc = "Show the names of the 4 areas while in the center of the Crystal Hollows.") diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt index af6a7dbfd..1404e685f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland @@ -13,13 +14,16 @@ 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.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.TimeUtils import io.github.moulberry.notenoughupdates.util.SkyBlockTime +import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.Collections class KingTalismanHelper { - private val config get() = SkyHanniMod.feature.mining + private val config get() = SkyHanniMod.feature.mining.kingTalisman + private var currentOffset: Int? = null private val kingLocation = LorenzVec(129.6, 196.5, 194.1) private val kingCircles = listOf( @@ -33,10 +37,11 @@ class KingTalismanHelper { ) private var allKingsDisplay = emptyList<String>() - private var farDisplay = "" + private var farDisplay = "Visit the king to sync up." private var display = emptyList<String>() - fun isNearby() = LorenzUtils.skyBlockArea == "Royal Palace" && kingLocation.distanceToPlayer() < 10 + private fun isNearby() = IslandType.DWARVEN_MINES.isInIsland() && LorenzUtils.skyBlockArea == "Royal Palace" && + kingLocation.distanceToPlayer() < 10 @SubscribeEvent fun onTick(event: LorenzTickEvent) { @@ -46,17 +51,48 @@ class KingTalismanHelper { display = emptyList() return } + val nearby = isNearby() + if (nearby) { + if (currentOffset == null) { + checkOffset() + } + } + + if (currentOffset == null) return update() - display = if (isNearby()) allKingsDisplay else Collections.singletonList(farDisplay) + display = if (nearby) allKingsDisplay else Collections.singletonList(farDisplay) + } + + private fun checkOffset() { + val currentKing = getCurrentKing() + + val king = + EntityUtils.getEntitiesNearby<EntityArmorStand>(LorenzVec(129.6, 196.0, 196.7), 2.0) + .filter { it.name.startsWith("§6§lKing ") }.first() + val foundKing = "§6§lKing (?<name>.*)".toPattern().matchMatcher(king.name) { + group("name") + } ?: return + + println(" ") + + val currentId = kingCircles.indexOf(currentKing) + println("currentKing: $currentKing $currentId") + + val foundId = kingCircles.indexOf(foundKing) + println("currentKing: $foundKing $foundId") + + currentOffset = currentId - foundId } - fun isEnabled() = config.kingTalismanHelper && IslandType.DWARVEN_MINES.isInIsland() + fun isEnabled() = config.enabled && LorenzUtils.inSkyBlock + && (IslandType.DWARVEN_MINES.isInIsland() || config.outsideMines) @SubscribeEvent fun onInventoryOpen(event: InventoryFullyOpenedEvent) { if (event.inventoryName != "Commissions") return if (!isEnabled()) return + if (currentOffset == null) return if (!isNearby()) return val profileSpecific = ProfileStorageData.profileSpecific ?: return @@ -120,12 +156,14 @@ class KingTalismanHelper { } private fun getKingTimes(): MutableMap<String, Long> { + val currentOffset = currentOffset ?: 0 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 + 2 - kingCircles.size) +// val startTime = SkyBlockTime(day = index + 2 - kingCircles.size) +// val startTime = SkyBlockTime(day = index - kingCircles.size) + val startTime = SkyBlockTime(day = index + currentOffset - kingCircles.size) var timeNext = startTime.toMillis() while (timeNext < System.currentTimeMillis()) { timeNext += oneCircleTime @@ -140,8 +178,8 @@ class KingTalismanHelper { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { - if (!config.kingTalismanHelper) return + if (!config.enabled) return - config.kingTalismanHelperPos.renderStrings(display, posLabel = "King Talisman Helper") + config.position.renderStrings(display, posLabel = "King Talisman Helper") } } |