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/bingo/BingoCardDisplay.kt | 1 - .../skyhanni/features/bingo/BingoNextStepHelper.kt | 13 ++++--------- .../skyhanni/features/bingo/MinionCraftHelper.kt | 20 ++++++-------------- 3 files changed, 10 insertions(+), 24 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features/bingo') 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() private val goalCompletePattern = "§6§lBINGO GOAL COMPLETE! §r§e(?.*)".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(?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 = "(?.*) Minion (?.*)".toPattern() - private var tick = 0 private var display = emptyList() 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 -- cgit