From a2ea62c88e4b7d25b27ccfde3d4d94d39c0a419f Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 25 Jul 2023 04:15:38 +0200 Subject: We do love LorenzTickEvent now --- .../skyhanni/features/fishing/BarnFishingTimer.kt | 14 +++++--------- .../hannibal2/skyhanni/features/fishing/OdgerWaypoint.kt | 9 +++------ .../skyhanni/features/fishing/SharkFishCounter.kt | 11 +++-------- .../skyhanni/features/fishing/ShowFishingItemName.kt | 9 +++------ 4 files changed, 14 insertions(+), 29 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features/fishing') diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt index 8ea8b1a59..b8c443eba 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt @@ -3,36 +3,32 @@ package at.hannibal2.skyhanni.features.fishing import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.RenderUtils.renderString import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class BarnFishingTimer { private val barnLocation = LorenzVec(108, 89, -252) - private var tick = 0 private var rightLocation = false private var currentCount = 0 private var startTime = 0L @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return + fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.inSkyBlock) return if (!SkyHanniMod.feature.fishing.barnTimer) return - tick++ - - if (tick % 60 == 0) checkIsland() + if (event.isMod(60)) checkIsland() if (!rightLocation) return - if (tick % 5 == 0) checkMobs() - if (tick % 7 == 0) tryPlaySound() + if (event.isMod(5)) checkMobs() + if (event.isMod(7)) tryPlaySound() } private fun tryPlaySound() { diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/OdgerWaypoint.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/OdgerWaypoint.kt index 0e8a61f87..bfcb94908 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/OdgerWaypoint.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/OdgerWaypoint.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.fishing import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -12,22 +13,18 @@ import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class OdgerWaypoint { private val location = LorenzVec(-373, 207, -808) - private var tick = 0 private var hasLavaRodInHand = false private var trophyFishInInv = false @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return - tick++ - if (tick % 10 == 0) { + if (event.isMod(10)) { hasLavaRodInHand = isLavaFishingRod() trophyFishInInv = InventoryUtils.getItemsInOwnInventory().map { it.getLore() } 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 4d4ec4455..57395fdc3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.fishing import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.SeaCreatureFishEvent import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -11,12 +12,10 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.renderString import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class SharkFishCounter { private var counter = 0 private var display = "" - private var tick = 0 private var hasWaterRodInHand = false @SubscribeEvent @@ -31,15 +30,11 @@ class SharkFishCounter { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return - + fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.inSkyBlock) return if (!SkyHanniMod.feature.fishing.sharkFishCounter) return - tick++ - - if (tick % 10 == 0) { + if (event.isMod(10)) { hasWaterRodInHand = isWaterFishingRod() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt index 9345b1552..addb6368c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.fishing import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.RenderUtils.drawString @@ -10,12 +11,10 @@ import com.google.common.cache.CacheBuilder import net.minecraft.entity.item.EntityItem import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import java.util.concurrent.TimeUnit class ShowFishingItemName { private val config get() = SkyHanniMod.feature.fishing.fishedItemName - private var tick = 0 private var hasRodInHand = false private var cache = CacheBuilder.newBuilder().expireAfterWrite(750, TimeUnit.MILLISECONDS) @@ -28,12 +27,10 @@ class ShowFishingItemName { ) @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return - tick++ - if (tick % 10 == 0) { + if (event.isMod(10)) { hasRodInHand = isFishingRod() } } -- cgit