diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-24 03:02:31 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-24 03:02:31 +0100 |
commit | fe042f73bcc8308b72ea7dc1720ea3192f08bd9e (patch) | |
tree | 632ed342ff5ef0fd87b8700c1c023dcba0ee02be /src/main/java/at | |
parent | 43f0e576509d54bb7b12ab59be292c261a0b050d (diff) | |
download | skyhanni-fe042f73bcc8308b72ea7dc1720ea3192f08bd9e.tar.gz skyhanni-fe042f73bcc8308b72ea7dc1720ea3192f08bd9e.tar.bz2 skyhanni-fe042f73bcc8308b72ea7dc1720ea3192f08bd9e.zip |
moved lastActiveFishingTime into FishingAPI
Diffstat (limited to 'src/main/java/at')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt | 27 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/fishing/FishingProfitTracker.kt | 29 |
2 files changed, 28 insertions, 28 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt index 3224b286b..ce48f2585 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt @@ -1,9 +1,12 @@ package at.hannibal2.skyhanni.features.fishing import at.hannibal2.skyhanni.events.FishingBobberCastEvent +import at.hannibal2.skyhanni.events.ItemInHandChangeEvent +import at.hannibal2.skyhanni.events.SkillExpGainEvent import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager.getFilletValue import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity +import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -17,12 +20,14 @@ import net.minecraft.init.Blocks import net.minecraft.item.ItemStack import net.minecraftforge.event.entity.EntityJoinWorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds object FishingAPI { private val lavaBlocks = listOf(Blocks.lava, Blocks.flowing_lava) private val waterBlocks = listOf(Blocks.water, Blocks.flowing_water) var lastCastTime = SimpleTimeMark.farPast() + var lastActiveFishingTime = SimpleTimeMark.farPast() @SubscribeEvent fun onJoinWorld(event: EntityJoinWorldEvent) { @@ -35,6 +40,28 @@ object FishingAPI { FishingBobberCastEvent(entity).postAndCatch() } + @SubscribeEvent + fun onItemInHandChange(event: ItemInHandChangeEvent) { + if (event.oldItem.isFishingRod()) { + lastActiveFishingTime = SimpleTimeMark.now() + } + if (event.newItem.isFishingRod()) { + DelayedRun.runDelayed(1.seconds) { + lastActiveFishingTime = SimpleTimeMark.now() + } + } + } + + @SubscribeEvent + fun onSkillExpGain(event: SkillExpGainEvent) { + val skill = event.skill + if (FishingProfitTracker.isEnabled()) { + if (skill != "fishing") { + lastActiveFishingTime = SimpleTimeMark.farPast() + } + } + } + fun hasFishingRodInHand() = InventoryUtils.itemInHandId.isFishingRod() fun NEUInternalName.isFishingRod() = contains("ROD") diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingProfitTracker.kt index bbc5fd7f8..67762542f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingProfitTracker.kt @@ -4,15 +4,12 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.EntityMoveEvent import at.hannibal2.skyhanni.events.FishingBobberCastEvent import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.ItemInHandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.SackChangeEvent -import at.hannibal2.skyhanni.events.SkillExpGainEvent import at.hannibal2.skyhanni.events.entity.ItemAddInInventoryEvent import at.hannibal2.skyhanni.features.bazaar.BazaarApi.Companion.getBazaarData -import at.hannibal2.skyhanni.features.fishing.FishingAPI.isFishingRod import at.hannibal2.skyhanni.test.PriceSource import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.ItemUtils.nameWithEnchantment @@ -50,8 +47,6 @@ object FishingProfitTracker { private val coinsChatPattern = ".* CATCH! §r§bYou found §r§6(?<coins>.*) Coins§r§b\\.".toPattern() private var lastClickDelay = 0L - private var lastFishingTime = SimpleTimeMark.farPast() - private val tracker = SkyHanniTracker("Fishing Profit Tracker", { Data() }, { it.fishing.fishingProfitTracker }) { drawDisplay(it) } @@ -248,28 +243,6 @@ object FishingProfitTracker { } @SubscribeEvent - fun onItemInHandChange(event: ItemInHandChangeEvent) { - if (event.oldItem.isFishingRod()) { - lastFishingTime = SimpleTimeMark.now() - } - if (event.newItem.isFishingRod()) { - DelayedRun.runDelayed(1.seconds) { - lastFishingTime = SimpleTimeMark.now() - } - } - } - - @SubscribeEvent - fun onSkillExpGain(event: SkillExpGainEvent) { - val skill = event.skill - if (isEnabled()) { - if (skill != "fishing") { - lastFishingTime = SimpleTimeMark.farPast() - } - } - } - - @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent) { if (!isEnabled()) return if (!FishingAPI.hasFishingRodInHand()) return @@ -279,7 +252,7 @@ object FishingProfitTracker { } private fun maybeAddItem(internalName: NEUInternalName, amount: Int) { - if (lastFishingTime.passedSince() > 10.minutes) return + if (FishingAPI.lastActiveFishingTime.passedSince() > 10.minutes) return if (!isAllowedItem(internalName)) { LorenzUtils.debug("Ignored non-fishing item pickup: $internalName'") |