aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/fishing/FishingProfitTrackerConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt30
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/FishingBaitWarnings.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/FishingDetection.kt96
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt29
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitPlayerMoving.kt43
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt5
10 files changed, 135 insertions, 85 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 080c38255..f769868a5 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -129,6 +129,7 @@ import at.hannibal2.skyhanni.features.fame.CityProjectFeatures
import at.hannibal2.skyhanni.features.fishing.ChumBucketHider
import at.hannibal2.skyhanni.features.fishing.FishingAPI
import at.hannibal2.skyhanni.features.fishing.FishingBaitWarnings
+import at.hannibal2.skyhanni.features.fishing.FishingDetection
import at.hannibal2.skyhanni.features.fishing.FishingHookDisplay
import at.hannibal2.skyhanni.features.fishing.FishingTimer
import at.hannibal2.skyhanni.features.fishing.SeaCreatureFeatures
@@ -137,7 +138,6 @@ import at.hannibal2.skyhanni.features.fishing.SeaCreatureMessageShortener
import at.hannibal2.skyhanni.features.fishing.SharkFishCounter
import at.hannibal2.skyhanni.features.fishing.ShowFishingItemName
import at.hannibal2.skyhanni.features.fishing.ThunderSparksHighlight
-import at.hannibal2.skyhanni.features.fishing.tracker.FishingProfitPlayerMoving
import at.hannibal2.skyhanni.features.fishing.tracker.FishingProfitTracker
import at.hannibal2.skyhanni.features.fishing.tracker.FishingTrackerCategoryManager
import at.hannibal2.skyhanni.features.fishing.tracker.SeaCreatureTracker
@@ -451,6 +451,7 @@ class SkyHanniMod {
loadModule(SackAPI)
loadModule(BingoAPI)
loadModule(FishingAPI)
+ loadModule(FishingDetection)
loadModule(LorenzUtils)
// features
@@ -632,7 +633,6 @@ class SkyHanniMod {
loadModule(FishingProfitTracker)
loadModule(FishingTrackerCategoryManager)
loadModule(SeaCreatureTracker)
- loadModule(FishingProfitPlayerMoving)
loadModule(SlayerItemsOnGround())
loadModule(RestorePieceOfWizardPortalLore())
loadModule(QuickModMenuSwitch)
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/FishingProfitTrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/FishingProfitTrackerConfig.java
index 4090e12dd..1b560e172 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/FishingProfitTrackerConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/FishingProfitTrackerConfig.java
@@ -18,11 +18,6 @@ public class FishingProfitTrackerConfig {
public Position position = new Position(20, 20, false, true);
@Expose
- @ConfigOption(name = "Hide Moving", desc = "Hide the Fishing Profit Tracker while moving.")
- @ConfigEditorBoolean
- public boolean hideMoving = true;
-
- @Expose
@ConfigOption(name = "Show When Pickup", desc = "Show the fishing tracker for a couple of seconds after catching something even while moving.")
@ConfigEditorBoolean
public boolean showWhenPickup = true;
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 a5f611827..6edc1be10 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt
@@ -13,10 +13,13 @@ import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import at.hannibal2.skyhanni.utils.getLorenzVec
import net.minecraft.client.Minecraft
+import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.entity.projectile.EntityFishHook
import net.minecraft.init.Blocks
import net.minecraft.item.ItemStack
@@ -92,4 +95,31 @@ object FishingAPI {
return info?.getFilletValue(rarity) ?: 0
}
+ fun isFishing() = FishingDetection.isFishing
+
+ fun seaCreatureCount(entity: EntityArmorStand): Int {
+ val name = entity.name
+ // a dragon, will always be fought
+ if (name == "Reindrake") return 0
+
+ // a npc shop
+ if (name == "§5Frosty the Snow Blaster") return 0
+
+ if (name == "Frosty") {
+ val npcLocation = LorenzVec(-1.5, 76.0, 92.5)
+ if (entity.getLorenzVec().distance(npcLocation) < 1) {
+ return 0
+ }
+ }
+
+ val isSummonedSoul = name.contains("'")
+ val hasFishingMobName = SeaCreatureManager.allFishingMobs.keys.any { name.contains(it) }
+ if (!hasFishingMobName || isSummonedSoul) return 0
+
+ if (name == "Sea Emperor" || name == "Rider of the Deep") {
+ return 2
+ }
+ return 1
+ }
+
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingBaitWarnings.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingBaitWarnings.kt
index 7785da356..1177ad7e2 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingBaitWarnings.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingBaitWarnings.kt
@@ -85,5 +85,5 @@ class FishingBaitWarnings {
LorenzUtils.chat("You do not use any fishing baits!")
}
- private fun isEnabled() = LorenzUtils.inSkyBlock && FishingAPI.hasFishingRodInHand() && !LorenzUtils.inKuudraFight
+ private fun isEnabled() = LorenzUtils.inSkyBlock && FishingAPI.isFishing() && !LorenzUtils.inKuudraFight
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingDetection.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingDetection.kt
new file mode 100644
index 000000000..38775705d
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingDetection.kt
@@ -0,0 +1,96 @@
+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
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import net.minecraft.entity.item.EntityArmorStand
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.time.Duration.Companion.minutes
+import kotlin.time.Duration.Companion.seconds
+
+object FishingDetection {
+ var isFishing = false
+ private var holdingRod = false
+ private var lastRodCastLocation: LorenzVec? = null
+ private var lastRodCastTime = SimpleTimeMark.farPast()
+ private var lastInAreaTime = SimpleTimeMark.farPast()
+
+ private var lastSeaCreatureKillArea: LorenzVec? = null
+ 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()
+ }
+
+ @SubscribeEvent
+ fun onTick(event: LorenzTickEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+
+ if (inRodCastArea()) {
+ lastInAreaTime = SimpleTimeMark.now()
+ }
+
+ if (lastInAreaTime.passedSince() < 5.seconds) {
+ if (EntityUtils.getEntitiesNextToPlayer<EntityArmorStand>(5.0)
+ .filter { FishingAPI.seaCreatureCount(it) > 0 }.any()
+ ) {
+ lastSeaCreatureKillArea = LocationUtils.playerLocation()
+ lastSeaCreatureKillAreaTime = SimpleTimeMark.now()
+ }
+ }
+
+ isFishing = testIsFishing()
+ }
+
+ private fun testIsFishing(): Boolean {
+ if (holdingRod) return true
+
+ if (inRodCastArea()) return true
+
+ if (lastRodCastTime.passedSince() < 5.seconds) return true
+
+ if (inKillArea()) return true
+
+
+ return false
+ }
+
+ private fun inRodCastArea(): Boolean {
+ if (lastRodCastTime.passedSince() < 2.minutes) {
+ lastRodCastLocation?.let {
+ if (it.distanceToPlayer() < 10) {
+ return true
+ }
+ }
+ }
+
+ return false
+ }
+
+ private fun inKillArea(): Boolean {
+ if (lastSeaCreatureKillAreaTime.passedSince() < 2.minutes) {
+ lastSeaCreatureKillArea?.let {
+ if (it.distanceToPlayer() < 10) {
+ return true
+ }
+ }
+ }
+
+ return false
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt
index 8f6988de7..2b633f0a4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt
@@ -16,7 +16,6 @@ import at.hannibal2.skyhanni.utils.SoundUtils
import at.hannibal2.skyhanni.utils.StringUtils
import at.hannibal2.skyhanni.utils.TimeUnit
import at.hannibal2.skyhanni.utils.TimeUtils
-import at.hannibal2.skyhanni.utils.getLorenzVec
import net.minecraft.client.Minecraft
import net.minecraft.entity.item.EntityArmorStand
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -77,32 +76,7 @@ class FishingTimer {
}
}
- private fun countMobs() = EntityUtils.getEntities<EntityArmorStand>().map { entity -> amount(entity) }.sum()
-
- private fun amount(entity: EntityArmorStand): Int {
- val name = entity.name
- // a dragon, will always be fought
- if (name == "Reindrake") return 0
-
- // a npc shop
- if (name == "§5Frosty the Snow Blaster") return 0
-
- if (name == "Frosty") {
- val npcLocation = LorenzVec(-1.5, 76.0, 92.5)
- if (entity.getLorenzVec().distance(npcLocation) < 1) {
- return 0
- }
- }
-
- val isSummonedSoul = name.contains("'")
- val hasFishingMobName = SeaCreatureManager.allFishingMobs.keys.any { name.contains(it) }
- if (!hasFishingMobName || isSummonedSoul) return 0
-
- if (name == "Sea Emperor" || name == "Rider of the Deep") {
- return 2
- }
- return 1
- }
+ private fun countMobs() = EntityUtils.getEntities<EntityArmorStand>().map { entity -> FishingAPI.seaCreatureCount(entity) }.sum()
private fun isRightLocation(): Boolean {
inHollows = false
@@ -131,6 +105,7 @@ class FishingTimer {
if (!config.enabled) return
if (!rightLocation) return
if (currentCount == 0) return
+ if (!FishingAPI.isFishing()) return
val duration = System.currentTimeMillis() - startTime
val barnTimerAlertTime = config.alertTime * 1_000
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt
index a5393dc6a..6e98cd134 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt
@@ -71,7 +71,7 @@ class SharkFishCounter {
else -> "How???"
}
- private fun isWaterFishingRod() = FishingAPI.hasFishingRodInHand() && !FishingAPI.isLavaRod()
+ private fun isWaterFishingRod() = FishingAPI.isFishing() && !FishingAPI.isLavaRod()
@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitPlayerMoving.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitPlayerMoving.kt
deleted file mode 100644
index ee19bab84..000000000
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitPlayerMoving.kt
+++ /dev/null
@@ -1,43 +0,0 @@
-package at.hannibal2.skyhanni.features.fishing.tracker
-
-import at.hannibal2.skyhanni.events.EntityMoveEvent
-import at.hannibal2.skyhanni.events.FishingBobberCastEvent
-import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
-import net.minecraft.client.Minecraft
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-
-object FishingProfitPlayerMoving {
-
- private val lastSteps = mutableListOf<Double>()
- var isMoving = true
-
- @SubscribeEvent
- fun onEntityMove(event: EntityMoveEvent) {
- if (!FishingProfitTracker.isEnabled() || !FishingProfitTracker.config.hideMoving) return
- if (event.entity != Minecraft.getMinecraft().thePlayer) return
-
- val distance = event.newLocation.distanceIgnoreY(event.oldLocation)
- if (distance < 0.1) {
- lastSteps.clear()
- return
- }
- lastSteps.add(distance)
- if (lastSteps.size > 20) {
- lastSteps.removeAt(0)
- }
- val total = lastSteps.sum()
- if (total > 3) {
- isMoving = true
- }
- }
-
- @SubscribeEvent
- fun onBobberThrow(event: FishingBobberCastEvent) {
- isMoving = false
- }
-
- @SubscribeEvent
- fun onWorldChange(event: LorenzWorldChangeEvent) {
- isMoving = 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 1ccac83de..ca6ef6f3d 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
@@ -175,9 +175,7 @@ object FishingProfitTracker {
val recentPickup = config.showWhenPickup && lastCatchTime.passedSince() < 3.seconds
if (!recentPickup) {
- if (!FishingAPI.hasFishingRodInHand()) return
- // TODO remove hide moving chech, replace with last cast location + radius
- if (FishingProfitPlayerMoving.isMoving && config.hideMoving) return
+ if (!FishingAPI.isFishing()) return
}
tracker.renderDisplay(config.position)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt
index c9168c306..258c06c12 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt
@@ -19,7 +19,6 @@ import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker
import at.hannibal2.skyhanni.utils.tracker.TrackerData
import com.google.gson.annotations.Expose
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import kotlin.time.Duration.Companion.minutes
object SeaCreatureTracker {
@@ -147,6 +146,7 @@ object SeaCreatureTracker {
@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent) {
if (!isEnabled()) return
+ if (!FishingAPI.isFishing()) return
tracker.renderDisplay(config.position)
}
@@ -155,6 +155,5 @@ object SeaCreatureTracker {
tracker.resetCommand(args, "shresetseacreaturetracker")
}
- private fun isEnabled() = LorenzUtils.inSkyBlock &&
- FishingAPI.lastActiveFishingTime.passedSince() < 10.minutes && config.enabled
+ private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled
}