aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorCalMWolfs <cwolfson58@gmail.com>2023-06-19 21:37:22 +1000
committerCalMWolfs <cwolfson58@gmail.com>2023-06-19 21:37:22 +1000
commit54cbf2fc5177ffc6b219a72be8032789ff3514b7 (patch)
treeaaea7f8277b39c1daca8bd13017befd33f7a351d /src/main/java/at/hannibal2
parentcd283aa10ba01dbd3162c4ebe2ddf3760ededbc9 (diff)
downloadskyhanni-54cbf2fc5177ffc6b219a72be8032789ff3514b7.tar.gz
skyhanni-54cbf2fc5177ffc6b219a72be8032789ff3514b7.tar.bz2
skyhanni-54cbf2fc5177ffc6b219a72be8032789ff3514b7.zip
done apart from testing
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Storage.java17
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Misc.java15
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/IslandType.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt125
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasures.kt2
5 files changed, 146 insertions, 14 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
index 0a63e5928..c0a003aad 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
@@ -5,7 +5,8 @@ import at.hannibal2.skyhanni.features.garden.CropAccessory;
import at.hannibal2.skyhanni.features.garden.CropType;
import at.hannibal2.skyhanni.features.garden.fortuneguide.FarmingItems;
import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward;
-import at.hannibal2.skyhanni.features.misc.GhostCounter.Option;
+import at.hannibal2.skyhanni.features.misc.FrozenTreasures;
+import at.hannibal2.skyhanni.features.misc.GhostCounter.Option;
import at.hannibal2.skyhanni.utils.LorenzVec;
import com.google.gson.annotations.Expose;
import net.minecraft.item.ItemStack;
@@ -229,6 +230,20 @@ public class Storage {
}
+ @Expose
+ public FrozenTreasureTracker frozenTreasureTracker = new FrozenTreasureTracker();
+
+ public static class FrozenTreasureTracker {
+ @Expose
+ public int treasuresMined = 0;
+
+ @Expose
+ public int compactProcs = 0;
+
+ @Expose
+ public Map<FrozenTreasures, Integer> treasureCount = new HashMap<>();
+ }
+
public long nextCityProjectParticipationTime = 0L;
@Expose
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
index f0d5b7d7b..ebfe716fe 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
@@ -1,13 +1,10 @@
package at.hannibal2.skyhanni.config.features;
-import at.hannibal2.skyhanni.config.core.config.*;
-import com.google.gson.annotations.*;
+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.observer.*;
-import org.lwjgl.input.*;
-
-import java.util.ArrayList;
-import java.util.List;
+import io.github.moulberry.moulconfig.observer.Property;
+import org.lwjgl.input.Keyboard;
import java.util.ArrayList;
import java.util.Arrays;
@@ -510,9 +507,9 @@ public class Misc {
exampleText = { // todo change colours
"§e§lFrozen Treasure Tracker",
"§e1,636 Treasures Mined",
- "§e3.2 Total Ice",
+ "§e3.2m Total Ice",
"§e342,192 Ice/hr",
- "§e31,002 Compact Procs",
+ "§e1,002 Compact Procs",
" ",
"§b182 §fWhite Gift",
"§b94 §aGreen Gift",
diff --git a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt
index 8b9c4dc3e..7935bf985 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt
@@ -18,6 +18,7 @@ enum class IslandType(val displayName: String, val apiName: String = "null") {
GARDEN("Garden"),
GARDEN_GUEST("Garden Guest"),
SPIDER_DEN("Spider's Den"),
+ WINTER("Jerry's Workshop"), //todo confirm
NONE(""),
UNKNOWN("???"),
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt
index fa947b022..bdb6db48d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt
@@ -1,19 +1,61 @@
package at.hannibal2.skyhanni.features.misc
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.IslandType
+import at.hannibal2.skyhanni.data.ProfileStorageData
+import at.hannibal2.skyhanni.data.ScoreboardData
+import at.hannibal2.skyhanni.events.ConfigLoadEvent
+import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.PreProfileSwitchEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
+import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy
+import at.hannibal2.skyhanni.utils.NumberUtil
+import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.concurrent.fixedRateTimer
class FrozenTreasureTracker {
private val config get() = SkyHanniMod.feature.misc.frozenTreasureTracker
private var display = listOf<List<Any>>()
- private var treasureMined = 0
+ private var treasuresMined = 0
private var compactProcs = 0
- private var estimatedIce = 0
+ private var estimatedIce = 0L
+ private var lastEstimatedIce = 0L
+ private val icePerMin = mutableListOf<Long>()
private var icePerHour = 0
+ private var missedMinutes = 0
+ private var compactPattern = "COMPACT! You found an Enchanted Ice!".toPattern()
private var treasureCount = mapOf<FrozenTreasures, Int>()
+ init {
+ fixedRateTimer(name = "skyhanni-dungeon-milestone-display", period = 60_000) {
+ if (!onJerryWorkshop()) return@fixedRateTimer
+ calculateIcePerHour()
+ }
+ }
+
+ private fun calculateIcePerHour() {
+ val difference = estimatedIce - lastEstimatedIce
+ if (difference == 0L) {
+ missedMinutes += 1
+ if (missedMinutes == 3) {
+ missedMinutes = 0
+ icePerMin.clear()
+ icePerHour = 0
+ }
+ return
+ }
+ missedMinutes = 0
+ icePerMin.add(difference)
+ icePerHour = icePerMin.average().toInt()
+ }
+
private fun formatDisplay(map: List<List<Any>>): List<List<Any>> {
val newList = mutableListOf<List<Any>>()
for (index in config.textFormat) {
@@ -23,11 +65,88 @@ class FrozenTreasureTracker {
}
@SubscribeEvent
+ fun onChat(event: LorenzChatEvent) {
+ if (!ProfileStorageData.loaded) return
+ if (!onJerryWorkshop()) return
+
+ val message = event.message.removeColor().trim()
+
+ compactPattern.matchMatcher(message) {
+ compactProcs += 1
+ saveAndUpdate()
+ if (config.hideMessages) event.isCanceled
+ }
+
+ for (treasure in FrozenTreasures.values()) {
+ if ("FROZEN TREASURE! You found ${treasure.displayName}!".toRegex().matches(message)) {
+ val old = treasureCount[treasure] ?: 0
+ treasureCount = treasureCount.editCopy { this[treasure] = old + 1 }
+ saveAndUpdate()
+ if (config.hideMessages) event.isCanceled
+ }
+ }
+ }
+
+ @SubscribeEvent
fun onPreProfileSwitch(event: PreProfileSwitchEvent) {
display = emptyList()
}
+ @SubscribeEvent
+ fun onConfigLoad(event: ConfigLoadEvent) {
+ val hidden = ProfileStorageData.profileSpecific?.frozenTreasureTracker ?: return
+ treasuresMined = hidden.treasuresMined
+ compactProcs = hidden.compactProcs
+ treasureCount = hidden.treasureCount
+ saveAndUpdate()
+ }
+
+ private fun drawTreasureDisplay() = buildList<List<Any>> {
+ addAsSingletonList("§e§lFrozen Treasure Tracker")
+ addAsSingletonList("§e${formatNumber(treasuresMined)} Treasures Mined")
+ addAsSingletonList("§e${formatNumber(estimatedIce)} Total Ice")
+ addAsSingletonList("§e${formatNumber(icePerHour)} Ice/hr")
+ addAsSingletonList("§e${formatNumber(compactProcs)} Compact Procs")
+ addAsSingletonList("")
+
+ for (treasure in FrozenTreasures.values()) {
+ val count = treasureCount[treasure] ?: 0
+ addAsSingletonList("§b${formatNumber(count)} ${treasure.displayName}")
+ }
+ addAsSingletonList("")
+ }
+
+ fun formatNumber(amount: Number): String {
+ if (amount is Int) return amount.addSeparators()
+ if (amount is Long) return NumberUtil.format(amount)
+ return "$amount"
+ }
+ private fun saveAndUpdate() {
+ val hidden = ProfileStorageData.profileSpecific?.frozenTreasureTracker ?: return
+ hidden.treasuresMined = treasuresMined
+ hidden.compactProcs = compactProcs
+ hidden.treasureCount = treasureCount
+ calculateIce()
+ display = formatDisplay(drawTreasureDisplay())
+ }
- //FROZEN TREASURE! You found Enchanted Ice!
+ private fun calculateIce() {
+ estimatedIce = 0
+ if (config.countCompact) estimatedIce += compactProcs * 160
+ for (treasure in FrozenTreasures.values()) {
+ val amount = treasureCount[treasure] ?: 0
+ estimatedIce += amount * treasure.defaultAmount * treasure.iceMultiplier
+ }
+ }
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) {
+ if (!config.enabled) return
+ if (!onJerryWorkshop()) return
+ if (config.onlyInCave && !inGlacialCave()) return
+ config.glacialDropPos.renderStringsAndItems(display, posLabel = "Visitor Stats")
+ }
+ private fun onJerryWorkshop() = LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.WINTER
+ private fun inGlacialCave() = onJerryWorkshop() && ScoreboardData.sidebarLinesFormatted.contains("Glacial Cave")
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasures.kt
index b2ede31d7..d9d936a31 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasures.kt
@@ -5,7 +5,7 @@ enum class FrozenTreasures (val internalName: String, val displayName: String, v
GREEN_GIFT("GREEN_GIFT", "§aGreen Gift",1),
RED_GIFT("RED_GIFT","§9§cRed Gift", 1),
PACKED_ICE("PACKED_ICE","§fPacked Ice", 32, 9),
- ENCHANTED_ICE("ENCHANTED_ICE","§aEnchanted Ice", 16, 160),
+ ENCHANTED_ICE("ENCHANTED_ICE","§aEnchanted Ice", 9, 160), // wiki says 1-16 so assuming 9
ENCHANTED_PACKED_ICE("ENCHANTED_PACKED_ICE", "§9Enchanted Packed Ice",1, 25600),
ICE_BAIT("ICE_BAIT","§aIce Bait", 16),
GLOWY_CHUM_BAIT("GLOWY_CHUM_BAIT", "§aGlowy Chum Bait",16),