aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/fishing
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-02-20 20:52:13 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-02-20 20:52:13 +0100
commit26932504f9788b14c23ef2ed2180971a58e4de68 (patch)
tree2c250268be8ea6429f07e98041c3bea6c2060849 /src/main/java/at/hannibal2/skyhanni/features/fishing
parent44f95162c63862c42c16a6111403766732bc9298 (diff)
downloadskyhanni-26932504f9788b14c23ef2ed2180971a58e4de68.tar.gz
skyhanni-26932504f9788b14c23ef2ed2180971a58e4de68.tar.bz2
skyhanni-26932504f9788b14c23ef2ed2180971a58e4de68.zip
Fixed adding drops to Fishing Profit Tracker while not actually fishing.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/fishing')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt16
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/IsFishingDetection.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/fishing/FishingDetection.kt)13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt1
4 files changed, 14 insertions, 18 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 a3d3a1cb7..e3ac0c219 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.fishing
import at.hannibal2.skyhanni.events.FishingBobberCastEvent
+import at.hannibal2.skyhanni.events.ItemInHandChangeEvent
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
@@ -27,10 +28,11 @@ object FishingAPI {
private val waterBlocks = listOf(Blocks.water, Blocks.flowing_water)
var lastCastTime = SimpleTimeMark.farPast()
+ var holdingRod = false
@SubscribeEvent
fun onJoinWorld(event: EntityJoinWorldEvent) {
- if (!LorenzUtils.inSkyBlock || !hasFishingRodInHand()) return
+ if (!LorenzUtils.inSkyBlock || !holdingRod) return
val entity = event.entity ?: return
if (entity !is EntityFishHook) return
if (entity.angler != Minecraft.getMinecraft().thePlayer) return
@@ -39,15 +41,19 @@ object FishingAPI {
FishingBobberCastEvent(entity).postAndCatch()
}
- fun hasFishingRodInHand() = InventoryUtils.itemInHandId.isFishingRod()
-
- fun NEUInternalName.isFishingRod() = contains("ROD")
+ private fun NEUInternalName.isFishingRod() = contains("ROD")
fun ItemStack.isBait(): Boolean {
val name = name ?: return false
return stackSize == 1 && (name.removeColor().startsWith("Obfuscated") || name.endsWith(" Bait"))
}
+ @SubscribeEvent
+ fun onItemInHandChange(event: ItemInHandChangeEvent) {
+ // TODO correct rod type per island water/lava
+ holdingRod = event.newItem.isFishingRod()
+ }
+
fun isLavaRod() = InventoryUtils.getItemInHand()?.getLore()?.any { it.contains("Lava Rod") } ?: false
fun getAllowedBlocks() = if (isLavaRod()) lavaBlocks else waterBlocks
@@ -62,7 +68,7 @@ object FishingAPI {
return info?.getFilletValue(rarity) ?: 0
}
- fun isFishing() = FishingDetection.isFishing
+ fun isFishing(checkRodInHand: Boolean = true) = IsFishingDetection.isFishing || (checkRodInHand && holdingRod)
fun seaCreatureCount(entity: EntityArmorStand): Int {
val name = entity.name
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt
index 73fe5e23a..671ae0841 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt
@@ -86,5 +86,5 @@ class FishingHookDisplay {
return pattern.matcher(name).matches()
}
- fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled && FishingAPI.hasFishingRodInHand()
+ fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled && FishingAPI.holdingRod
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingDetection.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/IsFishingDetection.kt
index bbd029100..1e3d73f5a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingDetection.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/IsFishingDetection.kt
@@ -1,9 +1,7 @@
package at.hannibal2.skyhanni.features.fishing
import at.hannibal2.skyhanni.events.FishingBobberCastEvent
-import at.hannibal2.skyhanni.events.ItemInHandChangeEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
-import at.hannibal2.skyhanni.features.fishing.FishingAPI.isFishingRod
import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
@@ -15,10 +13,9 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds
-object FishingDetection {
+object IsFishingDetection {
var isFishing = false
- private var holdingRod = false
private var lastRodCastLocation: LorenzVec? = null
private var lastRodCastTime = SimpleTimeMark.farPast()
private var lastInAreaTime = SimpleTimeMark.farPast()
@@ -27,12 +24,6 @@ object FishingDetection {
private var lastSeaCreatureKillAreaTime = SimpleTimeMark.farPast()
@SubscribeEvent
- fun onItemInHandChange(event: ItemInHandChangeEvent) {
- // TODO correct rod type per island water/lava
- holdingRod = event.newItem.isFishingRod()
- }
-
- @SubscribeEvent
fun onBobberThrow(event: FishingBobberCastEvent) {
lastRodCastLocation = LocationUtils.playerLocation()
lastRodCastTime = SimpleTimeMark.now()
@@ -59,8 +50,6 @@ object FishingDetection {
}
private fun testIsFishing(): Boolean {
- if (holdingRod) return true
-
if (inRodCastArea()) return true
if (lastRodCastTime.passedSince() < 5.seconds) return true
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt
index 1c5e6f7b6..6b7e7cea9 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt
@@ -221,6 +221,7 @@ object FishingProfitTracker {
}
private fun maybeAddItem(internalName: NEUInternalName, amount: Int) {
+ if (!FishingAPI.isFishing(checkRodInHand = false)) return
if (!isAllowedItem(internalName)) {
ChatUtils.debug("Ignored non-fishing item pickup: $internalName'")
return