aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt19
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt25
3 files changed, 34 insertions, 18 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
index 0cd806f57..b48805ef5 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
@@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.events.ProfileJoinEvent
import at.hannibal2.skyhanni.events.ScoreboardUpdateEvent
import at.hannibal2.skyhanni.events.WidgetUpdateEvent
import at.hannibal2.skyhanni.events.minecraft.ClientDisconnectEvent
+import at.hannibal2.skyhanni.events.skyblock.ScoreboardAreaChangeEvent
import at.hannibal2.skyhanni.features.bingo.BingoAPI
import at.hannibal2.skyhanni.features.dungeon.DungeonAPI
import at.hannibal2.skyhanni.features.rift.RiftAPI
@@ -319,8 +320,13 @@ object HypixelData {
loop@ for (line in ScoreboardData.sidebarLinesFormatted) {
skyblockAreaPattern.matchMatcher(line) {
val originalLocation = group("area").removeColor()
- skyBlockArea = LocationFixData.fixLocation(skyBlockIsland) ?: originalLocation
+ val area = LocationFixData.fixLocation(skyBlockIsland) ?: originalLocation
skyBlockAreaWithSymbol = line.trim()
+ if (area != skyBlockArea) {
+ val previousArea = skyBlockArea
+ skyBlockArea = area
+ ScoreboardAreaChangeEvent(area, previousArea).post()
+ }
break@loop
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt b/src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt
index 129e1cd95..20dfbb615 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt
@@ -11,9 +11,9 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@SkyHanniModule
object LocationFixData {
- private var locationFixes = mutableListOf<LocationFix>()
+ private var locationFixes = mutableMapOf<IslandType, List<LocationFix>>()
- class LocationFix(val island: IslandType, val area: AxisAlignedBB, val realLocation: String)
+ private data class LocationFix(val area: AxisAlignedBB, val realLocation: String)
// priority set to low so that IslandType can load their island names from repo earlier
@SubscribeEvent(priority = EventPriority.LOW)
@@ -26,11 +26,18 @@ object LocationFixData {
val area = fix.a.axisAlignedTo(fix.b)
val realLocation = fix.realLocation
- locationFixes.add(LocationFix(island, area, realLocation))
+ val list = locationFixes[island]
+
+ val locationFix = LocationFix(area, realLocation)
+
+ if (list == null) locationFixes[island] = listOf(locationFix)
+ else locationFixes[island] = list + locationFix
}
}
- fun fixLocation(skyBlockIsland: IslandType) = locationFixes
- .firstOrNull { skyBlockIsland == it.island && it.area.isPlayerInside() }
- ?.realLocation
+ fun fixLocation(skyBlockIsland: IslandType): String? =
+ locationFixes[skyBlockIsland]
+ ?.find { it.area.isPlayerInside() }
+ ?.realLocation
+
}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt
index 758294ffc..35855fc61 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt
@@ -1,8 +1,10 @@
package at.hannibal2.skyhanni.data
+import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.events.BlockClickEvent
import at.hannibal2.skyhanni.events.ColdUpdateEvent
import at.hannibal2.skyhanni.events.DebugDataCollectEvent
+import at.hannibal2.skyhanni.events.IslandChangeEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
@@ -11,6 +13,7 @@ import at.hannibal2.skyhanni.events.ScoreboardUpdateEvent
import at.hannibal2.skyhanni.events.ServerBlockChangeEvent
import at.hannibal2.skyhanni.events.mining.OreMinedEvent
import at.hannibal2.skyhanni.events.player.PlayerDeathEvent
+import at.hannibal2.skyhanni.events.skyblock.ScoreboardAreaChangeEvent
import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern
import at.hannibal2.skyhanni.features.mining.OreBlock
import at.hannibal2.skyhanni.features.mining.isTitanium
@@ -69,8 +72,6 @@ object MiningAPI {
var currentAreaOreBlocks = setOf<OreBlock>()
private set
- private var lastSkyblockArea: String? = null
-
private val recentClickedBlocks = ConcurrentSet<Pair<LorenzVec, SimpleTimeMark>>()
private val surroundingMinedBlocks = ConcurrentLinkedQueue<Pair<MinedBlock, LorenzVec>>()
private val allowedSoundNames = setOf("dig.glass", "dig.stone", "dig.gravel", "dig.cloth", "random.orb")
@@ -203,10 +204,6 @@ object MiningAPI {
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
if (!inCustomMiningIsland()) return
-
- if (LorenzUtils.lastWorldSwitch.passedSince() < 4.seconds) return
- updateLocation()
-
if (currentAreaOreBlocks.isEmpty()) return
// if somehow you take more than 20 seconds to mine a single block, congrats
@@ -219,6 +216,17 @@ object MiningAPI {
resetOreEvent()
}
+ @HandleEvent
+ fun onAreaChange(event: ScoreboardAreaChangeEvent) {
+ if (!inCustomMiningIsland()) return
+ updateLocation()
+ }
+
+ @SubscribeEvent
+ fun onIslandChange(event: IslandChangeEvent) {
+ updateLocation()
+ }
+
private fun runEvent() {
resetOreEvent()
@@ -287,11 +295,6 @@ object MiningAPI {
}
private fun updateLocation() {
- val currentArea = LorenzUtils.skyBlockArea
- // TODO add area change event with HypixelData.skyBlockArea instead
- if (currentArea == lastSkyblockArea) return
- lastSkyblockArea = currentArea
-
inGlacite = inGlaciteArea()
inTunnels = inGlacialTunnels()
inMineshaft = inMineshaft()