diff options
| author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-07-25 04:15:38 +0200 |
|---|---|---|
| committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-07-25 04:15:38 +0200 |
| commit | a2ea62c88e4b7d25b27ccfde3d4d94d39c0a419f (patch) | |
| tree | 3771b517ce72fe5c9a8b7e7020d15cafdf3a36b8 /src/main/java/at/hannibal2/skyhanni/features | |
| parent | de61fd6bccbea2a3ceca5a0707a3176938f24ead (diff) | |
| download | skyhanni-a2ea62c88e4b7d25b27ccfde3d4d94d39c0a419f.tar.gz skyhanni-a2ea62c88e4b7d25b27ccfde3d4d94d39c0a419f.tar.bz2 skyhanni-a2ea62c88e4b7d25b27ccfde3d4d94d39c0a419f.zip | |
We do love LorenzTickEvent now
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
52 files changed, 130 insertions, 269 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt index 899001e75..52227e4f7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt @@ -1,10 +1,7 @@ package at.hannibal2.skyhanni.features.bazaar import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.GuiContainerEvent -import at.hannibal2.skyhanni.events.InventoryCloseEvent -import at.hannibal2.skyhanni.events.InventoryOpenEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -18,7 +15,6 @@ import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class BazaarApi { private var loadedNpcPriceData = false @@ -60,8 +56,7 @@ class BazaarApi { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return + fun onTick(event: LorenzTickEvent) { if (!loadedNpcPriceData) { loadedNpcPriceData = true diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt index e650d71fb..7332c6571 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt @@ -26,7 +26,6 @@ class BingoCardDisplay { private val MAX_PERSONAL_GOALS = 20 private val MAX_COMMUNITY_GOALS = 5 - private var tick = 0 private var display = emptyList<String>() private val goalCompletePattern = "§6§lBINGO GOAL COMPLETE! §r§e(?<name>.*)".toPattern() diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt index 12f74a59f..82d2f4760 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.api.CollectionAPI import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.SkillExperience import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent import at.hannibal2.skyhanni.features.bingo.nextstep.* import at.hannibal2.skyhanni.utils.InventoryUtils @@ -15,13 +16,9 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matchRegex import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent - - class BingoNextStepHelper { private val config get() = SkyHanniMod.feature.bingo.bingoCard - private var tick = 0 private var dirty = true private val crystalObtainedPattern = " *§r§e(?<crystalName>Topaz|Sapphire|Jade|Amethyst|Amber) Crystal".toPattern() @@ -111,17 +108,15 @@ class BingoNextStepHelper { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.isBingoProfile) return if (!config.enabled) return - if (event.phase != TickEvent.Phase.START) return - tick++ - if (tick % 20 == 0) { + if (event.isMod(20)) { update() updateIslandsVisited() } - if (tick % 5 == 0) { + if (event.isMod(5)) { updateCurrentSteps() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt index ead79267c..41a601b0b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt @@ -2,10 +2,7 @@ package at.hannibal2.skyhanni.features.bingo import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.TitleUtils -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.InventoryOpenEvent -import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.ProfileJoinEvent +import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils @@ -19,11 +16,9 @@ import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe import net.minecraft.client.Minecraft import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class MinionCraftHelper { private var minionNamePattern = "(?<name>.*) Minion (?<number>.*)".toPattern() - private var tick = 0 private var display = emptyList<String>() private var hasMinionInInventory = false private var hasItemsForMinion = false @@ -38,19 +33,16 @@ class MinionCraftHelper { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return + fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.isBingoProfile) return if (!SkyHanniMod.feature.bingo.minionCraftHelperEnabled) return - tick++ - - if (tick % 10 == 0) { + if (event.isMod(10)) { val mainInventory = Minecraft.getMinecraft()?.thePlayer?.inventory?.mainInventory ?: return hasMinionInInventory = mainInventory.mapNotNull { it?.name }.any { isMinionName(it) } } - if (tick % (60 * 2) == 0) { + if (event.isMod(60 * 2)) { val mainInventory = Minecraft.getMinecraft()?.thePlayer?.inventory?.mainInventory ?: return hasItemsForMinion = loadFromInventory(mainInventory).first.isNotEmpty() } @@ -60,8 +52,8 @@ class MinionCraftHelper { return } - if (tick % 3 != 0) return -// if (tick % 60 != 0) return + if (!event.isMod(3)) return +// if (!event.isMod(60)) return val mainInventory = Minecraft.getMinecraft()?.thePlayer?.inventory?.mainInventory ?: return diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt index e2eae78f7..7403d2cb6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.chat import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LocationUtils @@ -11,21 +12,19 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.getLorenzVec import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class PlayerDeathMessages { - private var tick = 0 private val lastTimePlayerSeen = mutableMapOf<String, Long>() //§c ☠ §r§7§r§bZeroHazel§r§7 was killed by §r§8§lAshfang§r§7§r§7. private val deathMessagePattern = "§c ☠ §r§7§r§.(?<name>.+)§r§7 (?<reason>.+)".toPattern() @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!isHideFarDeathsEnabled()) return - if (tick++ % 20 == 0) { + if (event.isMod(20)) { checkOtherPlayers() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt index 637ca543e..a869e28fc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt @@ -28,7 +28,6 @@ import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.event.entity.EntityJoinWorldEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import java.util.* import kotlin.math.max @@ -294,7 +293,7 @@ class DamageIndicatorManager { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.inSkyBlock) return for (entity in EntityUtils.getEntities<EntityLivingBase>()) { checkEntity(entity) diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt index 883f2649f..50585d56e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt @@ -6,7 +6,6 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.equalsOneOf import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class DungeonData { private val floorPattern = " §7⏣ §cThe Catacombs §7\\((?<floor>.*)\\)".toPattern() @@ -51,8 +50,7 @@ class DungeonData { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return + fun onTick(event: LorenzTickEvent) { if (dungeonFloor == null) { for (line in ScoreboardData.sidebarLinesFormatted) { floorPattern.matchMatcher(line) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt index ec0df954e..f013abf07 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt @@ -4,10 +4,7 @@ package at.hannibal2.skyhanni.features.event.diana import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.TitleUtils -import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy import at.hannibal2.skyhanni.utils.StringUtils.cleanPlayerName @@ -20,7 +17,6 @@ import net.minecraftforge.event.entity.EntityJoinWorldEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.InputEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import org.lwjgl.input.Keyboard object InquisitorWaypointShare { @@ -36,7 +32,6 @@ object InquisitorWaypointShare { private var lastInquisitor = -1 private var lastShareTime = 0L private var inquisitorsNearby = emptyList<EntityOtherPlayerMP>() - private var tick = 0 private val logger = LorenzLogger("diana/waypoints") @@ -50,11 +45,10 @@ object InquisitorWaypointShare { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return - if (tick++ % 60 == 0) { + if (event.isMod(60)) { inquisitorsNearby = inquisitorsNearby.editCopy { removeIf { it.isDead } } } } 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) { |
