diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-24 03:12:22 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-24 03:12:22 +0100 |
commit | 1fad0bd83c258c4a907aeada1adc054a6cffa307 (patch) | |
tree | 01d6120ffe5855cdda7b26d1b161a3f6fccd8609 /src/main/java/at/hannibal2 | |
parent | 516a0679749f857d818685fa2cc3455670c75c6f (diff) | |
download | skyhanni-1fad0bd83c258c4a907aeada1adc054a6cffa307.tar.gz skyhanni-1fad0bd83c258c4a907aeada1adc054a6cffa307.tar.bz2 skyhanni-1fad0bd83c258c4a907aeada1adc054a6cffa307.zip |
moved Fishing tracker player moving check into own class
Diffstat (limited to 'src/main/java/at/hannibal2')
3 files changed, 47 insertions, 38 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 58d499439..34f7bfd3e 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -119,6 +119,7 @@ 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.trophy.OdgerWaypoint @@ -568,6 +569,7 @@ class SkyHanniMod { loadModule(SlayerProfitTracker) loadModule(FishingProfitTracker) loadModule(FishingTrackerCategoryManager) + loadModule(FishingProfitPlayerMoving) loadModule(SlayerItemsOnGround()) loadModule(RestorePieceOfWizardPortalLore()) loadModule(QuickModMenuSwitch) 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 new file mode 100644 index 000000000..ee19bab84 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitPlayerMoving.kt @@ -0,0 +1,43 @@ +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 5c5212937..3977172f1 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 @@ -1,11 +1,9 @@ package at.hannibal2.skyhanni.features.fishing.tracker 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.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.SackChangeEvent import at.hannibal2.skyhanni.events.entity.ItemAddInInventoryEvent import at.hannibal2.skyhanni.features.bazaar.BazaarApi.Companion.getBazaarData @@ -33,14 +31,13 @@ import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker import at.hannibal2.skyhanni.utils.tracker.TrackerData import com.google.gson.annotations.Expose -import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds object FishingProfitTracker { - private val config get() = SkyHanniMod.feature.fishing.fishingProfitTracker + val config get() = SkyHanniMod.feature.fishing.fishingProfitTracker private val coinsChatPattern = ".* CATCH! §r§bYou found §r§6(?<coins>.*) Coins§r§b\\.".toPattern() private var lastClickDelay = 0L @@ -244,7 +241,7 @@ object FishingProfitTracker { fun onRenderOverlay(event: GuiRenderEvent) { if (!isEnabled()) return if (!FishingAPI.hasFishingRodInHand()) return - if (isMoving && config.hideMoving) return + if (FishingProfitPlayerMoving.isMoving && config.hideMoving) return tracker.renderDisplay(config.position) } @@ -270,44 +267,11 @@ object FishingProfitTracker { else -> internalName.getNpcPriceOrNull() ?: 0.0 } - /// <editor-fold desc="isMoving"> - - private val lastSteps = mutableListOf<Double>() - private var isMoving = true - - @SubscribeEvent - fun onEntityMove(event: EntityMoveEvent) { - if (!isEnabled() || !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) { - if (!isEnabled() || !config.hideMoving) return - isMoving = false tracker.firstUpdate() } - @SubscribeEvent - fun onWorldChange(event: LorenzWorldChangeEvent) { - isMoving = true - } - /// </editor-fold> - fun resetCommand(args: Array<String>) { tracker.resetCommand(args, "shresetfishingtracker") } |