aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Storage.java4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/event/diana/AllBurrowsListConfig.java18
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/event/diana/DianaConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/AllBurrowsList.kt80
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt19
8 files changed, 131 insertions, 9 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 07d2e7aa9..6b74426d0 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -112,6 +112,7 @@ import at.hannibal2.skyhanni.features.dungeon.DungeonTeammateOutlines
import at.hannibal2.skyhanni.features.dungeon.HighlightDungeonDeathmite
import at.hannibal2.skyhanni.features.dungeon.TerracottaPhase
import at.hannibal2.skyhanni.features.event.UniqueGiftingOpportunitiesFeatures
+import at.hannibal2.skyhanni.features.event.diana.AllBurrowsList
import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper
import at.hannibal2.skyhanni.features.event.diana.DianaProfitTracker
import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowHelper
@@ -558,6 +559,7 @@ class SkyHanniMod {
loadModule(HighlightJerries())
loadModule(TheGreatSpook())
loadModule(GriffinBurrowHelper)
+ loadModule(AllBurrowsList)
loadModule(GriffinBurrowParticleFinder())
loadModule(BurrowWarpHelper())
loadModule(CollectionTracker())
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
index 125d395f8..647cb7ec1 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
@@ -67,8 +67,7 @@ class ConfigManager {
}
override fun read(reader: JsonReader): LorenzVec {
- val (x, y, z) = reader.nextString().split(":").map { it.toDouble() }
- return LorenzVec(x, y, z)
+ return LorenzVec.decodeFromString(reader.nextString())
}
}.nullSafe())
.registerTypeAdapter(TrophyRarity::class.java, object : TypeAdapter<TrophyRarity>() {
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
index 56a11626a..77b92131b 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
@@ -66,6 +66,9 @@ public class Storage {
public Map<String, SkyHanniTracker.DisplayMode> trackerDisplayModes = new HashMap<>();
@Expose
+ public List<LorenzVec> foundDianaBurrowLocations = new ArrayList<>();
+
+ @Expose
public Map<UUID, PlayerSpecific> players = new HashMap<>();
public static class PlayerSpecific {
@@ -467,7 +470,6 @@ public class Storage {
@Expose
// TODO renmae
public MythologicalCreatureTracker.Data mythologicalMobTracker = new MythologicalCreatureTracker.Data();
-
}
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
index b196bb634..680834317 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
@@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.features.chat.Translator
import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNodeTracker
import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil
import at.hannibal2.skyhanni.features.commands.PartyCommands
+import at.hannibal2.skyhanni.features.event.diana.AllBurrowsList
import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper
import at.hannibal2.skyhanni.features.event.diana.DianaProfitTracker
import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowHelper
@@ -421,6 +422,14 @@ object Commands {
"readcropmilestonefromclipboard",
"Read crop milestone from clipboard. This helps fixing wrong crop milestone data"
) { GardenCropMilestonesCommunityFix.readDataFromClipboard() }
+ registerCommand(
+ "shcopyfoundburrowlocations",
+ "Copy all ever found burrow locations to clipboard"
+ ) { AllBurrowsList.copyToClipboard() }
+ registerCommand(
+ "shaddfoundburrowlocationsfromclipboard",
+ "Add all ever found burrow locations from clipboard"
+ ) { AllBurrowsList.addFromClipboard() }
}
private fun internalCommands() {
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/AllBurrowsListConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/AllBurrowsListConfig.java
new file mode 100644
index 000000000..3dce0f375
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/AllBurrowsListConfig.java
@@ -0,0 +1,18 @@
+package at.hannibal2.skyhanni.config.features.event.diana;
+
+import com.google.gson.annotations.Expose;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.moulberry.moulconfig.annotations.ConfigOption;
+
+public class AllBurrowsListConfig {
+
+ @Expose
+ @ConfigOption(name = "Save Found Burrows", desc = "Save the location of every found burrow in a locally stored list.")
+ @ConfigEditorBoolean
+ public boolean save = true;
+
+ @Expose
+ @ConfigOption(name = "Show All Burrows", desc = "Show the list of all ever found burrows in the world.")
+ @ConfigEditorBoolean
+ public boolean showAll = false;
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/DianaConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/DianaConfig.java
index 4867c0bcd..fb992ab5f 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/DianaConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/DianaConfig.java
@@ -74,4 +74,9 @@ public class DianaConfig {
@Accordion
// TODO renmae
public MythologicalMobTrackerConfig mythologicalMobtracker = new MythologicalMobTrackerConfig();
+
+ @Expose
+ @ConfigOption(name = "All Burrows List", desc = "")
+ @Accordion
+ public AllBurrowsListConfig allBurrowsList = new AllBurrowsListConfig();
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/AllBurrowsList.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/AllBurrowsList.kt
new file mode 100644
index 000000000..f28c4966f
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/AllBurrowsList.kt
@@ -0,0 +1,80 @@
+package at.hannibal2.skyhanni.features.event.diana
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.BurrowDetectEvent
+import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
+import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
+import at.hannibal2.skyhanni.utils.LorenzColor
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.OSUtils
+import at.hannibal2.skyhanni.utils.RenderUtils.drawColor
+import kotlinx.coroutines.launch
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+object AllBurrowsList {
+ private var list = listOf<LorenzVec>()
+ private val config get() = SkyHanniMod.feature.event.diana.allBurrowsList
+ private val burrowLocations get() = SkyHanniMod.feature.storage?.foundDianaBurrowLocations
+
+ @SubscribeEvent
+ fun onBurrowDetect(event: BurrowDetectEvent) {
+ if (!isEnabled()) return
+ burrowLocations?.add(event.burrowLocation)
+ }
+
+ @SubscribeEvent
+ fun onTick(event: LorenzTickEvent) {
+ if (!isEnabled()) return
+ if (!event.repeatSeconds(1)) return
+ val burrowLocations = burrowLocations ?: return
+
+ val range = 5..70
+ list = burrowLocations.asSequence().map { it to it.distanceToPlayer() }
+ .filter { it.second.toInt() in range }
+ .sortedBy { it.second }
+ .map { it.first }
+ .take(25).toList()
+ }
+
+ fun copyToClipboard() {
+ val burrowLocations = burrowLocations ?: return
+ val list = burrowLocations.map { it.printWithAccuracy(0, ":") }
+ OSUtils.copyToClipboard(list.joinToString(";"))
+ LorenzUtils.chat("Saved all ${list.size} burrow locations to clipboard.")
+ }
+
+ fun addFromClipboard() {
+ SkyHanniMod.coroutineScope.launch {
+ val text = OSUtils.readFromClipboard() ?: return@launch
+ val burrowLocations = burrowLocations ?: return@launch
+
+ var new = 0
+ var duplicate = 0
+ for (raw in text.split(";")) {
+ val location = LorenzVec.decodeFromString(raw)
+ if (location !in burrowLocations) {
+ burrowLocations.add(location)
+ new++
+ } else {
+ duplicate++
+ }
+ }
+ ChatUtils.chat("Added $new new burrow locations, $duplicate are duplicate.")
+ }
+ }
+
+ @SubscribeEvent
+ fun onRenderWorld(event: LorenzRenderWorldEvent) {
+ if (!isEnabled()) return
+ if (!config.showAll) return
+
+ for (location in list) {
+ event.drawColor(location, LorenzColor.DARK_AQUA)
+ }
+ }
+
+ fun isEnabled() = DianaAPI.isDoingDiana() && config.save
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
index 03f623f70..ad85619b1 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
@@ -66,11 +66,18 @@ data class LorenzVec(
fun normalize() = length().let { LorenzVec(x / it, y / it, z / it) }
- fun printWithAccuracy(accuracy: Int): String {
- val x = (round(x * accuracy) / accuracy)
- val y = (round(y * accuracy) / accuracy)
- val z = (round(z * accuracy) / accuracy)
- return LorenzVec(x, y, z).toCleanString()
+ fun printWithAccuracy(accuracy: Int, splitChar: String = " "): String {
+ return if (accuracy == 0) {
+ val x = round(x).toInt()
+ val y = round(y).toInt()
+ val z = round(z).toInt()
+ "$x$splitChar$y$splitChar$z"
+ } else {
+ val x = (round(x * accuracy) / accuracy)
+ val y = (round(y * accuracy) / accuracy)
+ val z = (round(z * accuracy) / accuracy)
+ "$x$splitChar$y$splitChar$z"
+ }
}
private fun toCleanString(): String {
@@ -155,7 +162,7 @@ data class LorenzVec(
return LorenzVec(x, z, y)
}
- // only for migration purposes
+ // Format: "x:y:z"
fun decodeFromString(string: String): LorenzVec {
val (x, y, z) = string.split(":").map { it.toDouble() }
return LorenzVec(x, y, z)