diff options
author | Empa <42304516+ItsEmpa@users.noreply.github.com> | 2024-09-21 11:18:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-21 11:18:41 +0200 |
commit | 208fc04e7db767abda24fdbae141d60898371d61 (patch) | |
tree | 1f40e682a3dec8d6ee673672ca9a0ba493e183a5 /src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt | |
parent | f298d65f6b3029474f6695ccf3cb6ac5f0400e42 (diff) | |
download | skyhanni-208fc04e7db767abda24fdbae141d60898371d61.tar.gz skyhanni-208fc04e7db767abda24fdbae141d60898371d61.tar.bz2 skyhanni-208fc04e7db767abda24fdbae141d60898371d61.zip |
Backend: AreaChangeEvent and Islands in HandleEvent (#2535)
Co-authored-by: ItsEmpa <itsempa@users.noreply.github.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt | 25 |
1 files changed, 14 insertions, 11 deletions
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() |