aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt27
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/FishingProfitTracker.kt29
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'")