diff options
Diffstat (limited to 'src/main/java')
67 files changed, 159 insertions, 328 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 042dec43c..ddd334c76 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.config.Features import at.hannibal2.skyhanni.config.commands.Commands.init import at.hannibal2.skyhanni.data.* import at.hannibal2.skyhanni.data.repo.RepoManager +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.anvil.AnvilCombineHelper import at.hannibal2.skyhanni.features.bazaar.BazaarApi import at.hannibal2.skyhanni.features.bazaar.BazaarBestSellMethod @@ -108,7 +109,6 @@ import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.event.FMLInitializationEvent import net.minecraftforge.fml.common.event.FMLPreInitializationEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent import org.apache.logging.log4j.Level import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.Logger @@ -393,7 +393,7 @@ class SkyHanniMod { } @SubscribeEvent - fun onClientTick(event: ClientTickEvent?) { + fun onTick(event: LorenzTickEvent) { if (screenToOpen != null) { screenTicks++ if (screenTicks == 5) { diff --git a/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt b/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt index 54a914e72..54d86d1de 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.utils.APIUtil @@ -10,7 +11,6 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import java.io.File import java.util.* @@ -20,7 +20,7 @@ class ApiDataLoader { private var currentProfileId = "" @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { val thePlayer = Minecraft.getMinecraft().thePlayer ?: return thePlayer.worldObj ?: return diff --git a/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt index 2899999c3..c3cbab117 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt @@ -1,9 +1,6 @@ package at.hannibal2.skyhanni.data -import at.hannibal2.skyhanni.events.InventoryCloseEvent -import at.hannibal2.skyhanni.events.InventoryOpenEvent -import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent -import at.hannibal2.skyhanni.events.ProfileJoinEvent +import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.features.garden.CropAccessory import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.utils.InventoryUtils @@ -15,7 +12,6 @@ import net.minecraft.item.ItemStack import net.minecraft.nbt.CompressedStreamTools import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import java.io.ByteArrayInputStream import java.util.* @@ -88,8 +84,8 @@ class CropAccessoryData { // Handle inventory detection @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START || ticks++ % 20 != 0) return + fun onTick(event: LorenzTickEvent) { + if (!event.isMod(20)) return if (!LorenzUtils.inSkyBlock) return accessoryInInventory = bestCropAccessory(InventoryUtils.getItemsInOwnInventory()) if (accessoryInInventory == CropAccessory.NONE) return diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt index 14d102a50..0bc742198 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt @@ -1,9 +1,6 @@ package at.hannibal2.skyhanni.data -import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent -import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent -import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth import net.minecraft.client.Minecraft @@ -17,16 +14,13 @@ import net.minecraft.entity.item.EntityItemFrame import net.minecraft.entity.item.EntityXPOrb import net.minecraft.network.play.server.S1CPacketEntityMetadata import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class EntityData { private val maxHealthMap = mutableMapOf<EntityLivingBase, Int>() @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return - + fun onTick(event: LorenzTickEvent) { val entities = EntityUtils.getEntitiesOrNull<EntityLivingBase>() ?: return for (entity in entities) { val maxHealth = entity.baseMaxHealth diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt index abab3c002..d67ae4a63 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt @@ -1,13 +1,13 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.EntityMoveEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.getLorenzVec import net.minecraft.entity.Entity import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class EntityMovementData { @@ -22,7 +22,7 @@ class EntityMovementData { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.inSkyBlock) return for (entity in entityLocation.keys) { diff --git a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt index f3d734dcb..be373f62f 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.core.config.Position import at.hannibal2.skyhanni.config.core.config.gui.GuiPositionEditor import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isRancherSign import at.hannibal2.skyhanni.utils.NEUItems @@ -14,15 +15,13 @@ import net.minecraft.client.gui.inventory.GuiInventory import net.minecraft.client.renderer.GlStateManager import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import org.lwjgl.input.Keyboard import java.util.* class GuiEditManager { - // TODO Make utils method for this @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.inSkyBlock) return Minecraft.getMinecraft().currentScreen?.let { diff --git a/src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt b/src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt index 7c4cfd7c1..ac6c82044 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigManager +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.utils.APIUtil import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.jsonobjects.MayorJson @@ -10,10 +11,8 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class MayorElection { - private var tick = 0 private var lastUpdate = 0L companion object { @@ -30,13 +29,10 @@ class MayorElection { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return + fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.onHypixel) return - tick++ - - if (tick % 60 == 0) { + if (event.isMod(60)) { check() } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt b/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt index a68a0af70..c28db9a9d 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt @@ -60,7 +60,6 @@ class MinecraftData { @SubscribeEvent fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return Minecraft.getMinecraft().thePlayer ?: return tick++ LorenzTickEvent(tick).postAndCatch() diff --git a/src/main/java/at/hannibal2/skyhanni/data/OtherInventoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/OtherInventoryData.kt index f1cebf640..77921029b 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/OtherInventoryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/OtherInventoryData.kt @@ -6,7 +6,6 @@ import net.minecraft.network.play.server.S2DPacketOpenWindow import net.minecraft.network.play.server.S2EPacketCloseWindow import net.minecraft.network.play.server.S2FPacketSetSlot import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent object OtherInventoryData { private var currentInventory: Inventory? = null @@ -26,8 +25,7 @@ object OtherInventoryData { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return + fun onTick(event: LorenzTickEvent) { lateEvent?.let { it.postAndCatch() lateEvent = null diff --git a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt index 8b55ab189..9c2fff90d 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt @@ -8,7 +8,6 @@ import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent object ProfileStorageData { var playerSpecific: Storage.PlayerSpecific? = null @@ -75,8 +74,7 @@ object ProfileStorageData { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return + fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.inSkyBlock) return if (noTabListTime == -1L) return diff --git a/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt index 750e23794..d41e5ad7a 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt @@ -1,13 +1,13 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.PurseChangeCause import at.hannibal2.skyhanni.events.PurseChangeEvent import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class PurseAPI { private val pattern = "(Piggy|Purse): §6(?<coins>[\\d,]*).*".toPattern() @@ -20,8 +20,7 @@ class PurseAPI { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return + fun onTick(event: LorenzTickEvent) { for (line in ScoreboardData.sidebarLinesFormatted) { val newPurse = pattern.matchMatcher(line) { diff --git a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt index 9602c1b59..4f72ba3e3 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ScoreboardChangeEvent import at.hannibal2.skyhanni.events.ScoreboardRawChangeEvent import net.minecraft.client.Minecraft @@ -7,7 +8,6 @@ import net.minecraft.scoreboard.Score import net.minecraft.scoreboard.ScorePlayerTeam import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class ScoreboardData { @@ -52,8 +52,7 @@ class ScoreboardData { } @SubscribeEvent(priority = EventPriority.HIGHEST) - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return + fun onTick(event: LorenzTickEvent) { val list = fetchScoreboardLines().reversed() val semiFormatted = list.map { cleanSB(it) } diff --git a/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt index aa41560eb..6b8af2941 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt @@ -1,9 +1,6 @@ package at.hannibal2.skyhanni.data -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.SlayerChangeEvent -import at.hannibal2.skyhanni.events.SlayerProgressChangeEvent -import at.hannibal2.skyhanni.events.SlayerQuestCompleteEvent +import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.features.bazaar.BazaarApi import at.hannibal2.skyhanni.features.slayer.SlayerType import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -16,13 +13,10 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import com.google.common.cache.CacheBuilder import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import java.util.concurrent.TimeUnit object SlayerAPI { - var tick = 0 - private var nameCache = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).build<Pair<String, Int>, Pair<String, Double>>() @@ -103,8 +97,7 @@ object SlayerAPI { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return + fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.inSkyBlock) return // wait with sending SlayerChangeEvent until profile is detected @@ -124,7 +117,7 @@ object SlayerAPI { latestProgressChangeTime = System.currentTimeMillis() } - if (tick++ % 5 == 0) { + if (event.isMod(5)) { isInSlayerArea = SlayerType.getByArea(LorenzUtils.skyBlockArea) != null } } 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) { 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() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt index 486b762a7..8465ded13 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt @@ -23,7 +23,6 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import kotlin.math.floor import kotlin.math.log10 @@ -34,7 +33,6 @@ class FarmingFortuneDisplay { private var accessoryProgressDisplay = "" private var lastToolSwitch: Long = 0 - private var ticks: Int = 0 @SubscribeEvent fun onPreProfileSwitch(event: PreProfileSwitchEvent) { @@ -88,8 +86,8 @@ class FarmingFortuneDisplay { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START || ticks++ % 5 != 0) return + fun onTick(event: LorenzTickEvent) { + if (!event.isMod(5)) return val displayCrop = currentCrop ?: return val updatedDisplay = mutableListOf<List<Any>>() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt index af1660def..d50ec8094 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -27,7 +27,6 @@ import net.minecraft.item.ItemStack import net.minecraft.network.play.client.C09PacketHeldItemChange import net.minecraft.util.AxisAlignedBB import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import kotlin.time.Duration.Companion.seconds object GardenAPI { @@ -39,7 +38,6 @@ object GardenAPI { val onBarnPlot get() = inBarn && inGarden() val config get() = ProfileStorageData.profileSpecific?.garden - var tick = 0 private val barnArea = AxisAlignedBB(35.5, 70.0, -4.5, -32.5, 100.0, -46.5) @SubscribeEvent @@ -56,11 +54,9 @@ object GardenAPI { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return + fun onTick(event: LorenzTickEvent) { if (!inGarden()) return - tick++ - if (tick % 10 == 0) { + if (event.isMod(10)) { inBarn = barnArea.isPlayerInside() // We ignore random hypixel moments diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt index dfe17b1c0..bbebcc9b4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt @@ -17,7 +17,6 @@ import io.github.moulberry.notenoughupdates.util.SkyBlockTime import kotlinx.coroutines.launch import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import org.lwjgl.opengl.Display import java.awt.event.MouseAdapter import java.awt.event.MouseEvent @@ -30,7 +29,6 @@ import javax.swing.UIManager class GardenNextJacobContest { private var display = emptyList<Any>() private var simpleDisplay = emptyList<String>() - private var tick = 0 private var contests = mutableMapOf<Long, FarmingContest>() private var inCalendar = false private val patternDay = "§aDay (?<day>.*)".toPattern() @@ -66,9 +64,9 @@ class GardenNextJacobContest { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return - if (tick++ % (40) != 0) return + if (!event.isMod(40)) return if (inCalendar) return update() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt index e1574efc0..5c2f569cb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt @@ -26,7 +26,6 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates import net.minecraftforge.event.entity.player.ItemTooltipEvent 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.ceil import kotlin.time.Duration @@ -94,7 +93,7 @@ class ComposterOverlay { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!GardenAPI.inGarden()) return if (inComposterUpgrades) { if (extraComposterUpgrade != null) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt index 6e279e7d2..21bbf3e08 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt @@ -1,10 +1,7 @@ package at.hannibal2.skyhanni.features.garden.contest import at.hannibal2.skyhanni.data.ScoreboardData -import at.hannibal2.skyhanni.events.FarmingContestEvent -import at.hannibal2.skyhanni.events.GuiContainerEvent -import at.hannibal2.skyhanni.events.InventoryCloseEvent -import at.hannibal2.skyhanni.events.InventoryOpenEvent +import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -14,13 +11,11 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import io.github.moulberry.notenoughupdates.util.SkyBlockTime import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent object FarmingContestAPI { private val timePattern = "§a(?<month>.*) (?<day>.*)(?:rd|st|nd|th), Year (?<year>.*)".toPattern() private val contests = mutableMapOf<Long, FarmingContest>() private val cropPattern = "§8(?<crop>.*) Contest".toPattern() - private var tick = 0 var inContest = false var contestCrop: CropType? = null private val sidebarCropPattern = "§e○ §f(?<crop>.*) §a.*".toPattern() @@ -28,11 +23,8 @@ object FarmingContestAPI { var inInventory = false @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return - tick++ - - if (tick % 20 == 0) { + fun onTick(event: LorenzTickEvent) { + if (event.isMod(20)) { if (!LorenzUtils.inSkyBlock) return if (!GardenAPI.inGarden()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt index 73a5cee71..0bacfe260 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.garden.farming import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.PreProfileSwitchEvent import at.hannibal2.skyhanni.features.bazaar.BazaarApi import at.hannibal2.skyhanni.features.bazaar.BazaarData @@ -26,7 +27,6 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getReforgeName import at.hannibal2.skyhanni.utils.StringUtils.removeColor import kotlinx.coroutines.launch import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent object CropMoneyDisplay { var multipliers = mapOf<String, Int>() @@ -40,7 +40,6 @@ object CropMoneyDisplay { private var display = emptyList<List<Any>>() private val config get() = SkyHanniMod.feature.garden - private var tick = 0 private var loaded = false private var ready = false private val cropNames = mutableMapOf<String, CropType>() // internalName -> cropName @@ -66,9 +65,9 @@ object CropMoneyDisplay { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return - if (tick++ % (20 * 5) != 0) return + if (!event.isMod(20 * 5)) return if (GardenAPI.getCurrentlyFarmedCrop() == null && !config.moneyPerHourAlwaysOn) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt index e65aa351e..b079782a8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter import at.hannibal2.skyhanni.events.CropClickEvent import at.hannibal2.skyhanni.events.CropMilestoneUpdateEvent import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.utils.LorenzUtils @@ -12,13 +13,11 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class CropSpeedMeter { private var display = emptyList<String>() private var currentCrop: CropType? = null private var currentBlocks = 0 - private var tick = 0 private var snapshot = emptyList<String>() @SubscribeEvent @@ -36,9 +35,9 @@ class CropSpeedMeter { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return - if (tick++ % 30 != 0) return + if (!event.isMod(30)) return updateDisplay() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt index e43ffa3a8..e4faf5f61 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt @@ -1,10 +1,7 @@ package at.hannibal2.skyhanni.features.garden.farming import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.ConfigLoadEvent -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.PreProfileSwitchEvent +import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -12,13 +9,11 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class FarmingArmorDrops { private var display = emptyList<String>() private val drops = mutableMapOf<ArmorDropType, Int>() private var hasArmor = false - private var tick = 0 private val armorPattern = "(FERMENTO|CROPIE|SQUASH|MELON)_(LEGGINGS|CHESTPLATE|BOOTS|HELMET)".toPattern() private val config get() = SkyHanniMod.feature.garden @@ -96,13 +91,11 @@ class FarmingArmorDrops { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return + fun onTick(event: LorenzTickEvent) { if (!GardenAPI.inGarden()) return if (!config.farmingArmorDropsEnabled) return - tick++ - if (tick % 30 == 0) { + if (event.isMod(30)) { checkArmor() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt index ce36238e2..51bb0af43 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt @@ -2,10 +2,7 @@ package at.hannibal2.skyhanni.features.garden.farming import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.HypixelData -import at.hannibal2.skyhanni.events.GardenToolChangeEvent -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.PreProfileSwitchEvent +import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed @@ -17,7 +14,6 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import java.util.* class FarmingWeightDisplay { @@ -59,12 +55,10 @@ class FarmingWeightDisplay { nextPlayers.clear() } - var tick = 0 - @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return - if (tick++ % 5 != 0) return + if (!event.isMod(5)) return update() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt index a49a282a7..5b0aafdb9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt @@ -38,7 +38,6 @@ import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.event.entity.player.ItemTooltipEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import kotlin.math.round private val config get() = SkyHanniMod.feature.garden @@ -47,7 +46,6 @@ class GardenVisitorFeatures { private val visitors = mutableMapOf<String, Visitor>() private var display = emptyList<List<Any>>() private var lastClickedNpc = 0 - private var tick = 0 private val newVisitorArrivedMessage = ".* §r§ehas arrived on your §r§bGarden§r§e!".toPattern() private val copperPattern = " §8\\+§c(?<amount>.*) Copper".toPattern() private val gardenExperiencePattern = " §8\\+§2(?<amount>.*) §7Garden Experience".toPattern() @@ -419,11 +417,11 @@ class GardenVisitorFeatures { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!GardenAPI.inGarden()) return if (!config.visitorNeedsDisplay && config.visitorHighlightStatus == 3) return - if (tick++ % 10 != 0) return -// if (tick++ % 300 != 0) return + if (!event.isMod(10)) return +// if (!event.isMod(300)) return if (GardenAPI.onBarnPlot && config.visitorHighlightStatus != 3) { checkVisitorsReady() diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt index b86aec0c6..e7137bf17 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt @@ -16,11 +16,9 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher 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 ItemAbilityCooldown { private var lastAbility = "" - var tick = 0 var items = mapOf<ItemStack, List<ItemText>>() private val youAlignedOthersPattern = "§eYou aligned §r§a.* §r§eother player(s)?!".toPattern() @@ -203,11 +201,10 @@ class ItemAbilityCooldown { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return - tick++ - if (tick % 2 == 0) { + if (event.isMod(2)) { checkHotBar() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt index 6d2d5c4e4..1bdf8e90c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt @@ -26,7 +26,6 @@ import net.minecraftforge.client.event.RenderWorldLastEvent 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.Mouse import java.awt.Color @@ -140,7 +139,7 @@ class MinionFeatures { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (LorenzUtils.skyBlockIsland != IslandType.PRIVATE_ISLAND) return if (coinsPerDay != "") return diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ChickenHeadTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ChickenHeadTimer.kt index ad4ba25ed..8a7dc645f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ChickenHeadTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ChickenHeadTimer.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.misc 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.LorenzWorldChangeEvent import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -10,18 +11,16 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.TimeUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class ChickenHeadTimer { - private var tick = 0 private var hasChickenHead = false private var lastTime = 0L private val config get() = SkyHanniMod.feature.misc @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return - if (tick++ % 5 != 0) return + if (!event.isMod(5)) return val itemStack = InventoryUtils.getArmor()[3] val name = itemStack?.name ?: "" diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CityProjectFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CityProjectFeatures.kt index 1610b3ef4..a00477b07 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CityProjectFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CityProjectFeatures.kt @@ -2,10 +2,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ProfileStorageData -import at.hannibal2.skyhanni.events.GuiContainerEvent -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.InventoryCloseEvent -import at.hannibal2.skyhanni.events.InventoryOpenEvent +import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.features.bazaar.BazaarApi import at.hannibal2.skyhanni.features.garden.contest.FarmingContestAPI import at.hannibal2.skyhanni.utils.* @@ -23,12 +20,10 @@ import net.minecraft.client.gui.inventory.GuiEditSign 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 CityProjectFeatures { private var display = emptyList<List<Any>>() private var inInventory = false - private var tick = 0 private var lastReminderSend = 0L private val contributeAgainPattern = "§7Contribute again: §e(?<time>.*)".toPattern() @@ -41,11 +36,9 @@ class CityProjectFeatures { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.inSkyBlock) return - if (event.phase != TickEvent.Phase.START) return - tick++ - if (tick % 20 == 0) { + if (event.isMod(20)) { checkDailyReminder() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt index 8915ff071..ef23583e3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.CollectionAPI import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -12,7 +13,6 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class CollectionCounter { @@ -123,7 +123,7 @@ class CollectionCounter { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { val thePlayer = Minecraft.getMinecraft().thePlayer ?: return thePlayer.worldObj ?: return diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt index 6ed5918bb..8916fb0ec 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt @@ -8,7 +8,6 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class MarkedPlayerManager { @@ -72,13 +71,11 @@ class MarkedPlayerManager { } } - var tick = 0 - @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.inSkyBlock) return - if (tick++ % 20 == 0) { + if (event.isMod(20)) { findPlayers() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt index 3ba0acceb..0cc9dd7fe 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt @@ -15,14 +15,12 @@ import at.hannibal2.skyhanni.utils.TimeUtils import net.minecraft.network.play.server.S47PacketPlayerListHeaderFooter import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class NonGodPotEffectDisplay { private val config get() = SkyHanniMod.feature.misc private var checkFooter = false private val effectDuration = mutableMapOf<NonGodPotEffect, Long>() private var display = emptyList<String>() - private var lastTick = 0L enum class NonGodPotEffect(val apiName: String, val displayName: String, val isMixin: Boolean = false) { SMOLDERING("smoldering_polarization", "§aSmoldering Polarization I"), @@ -128,10 +126,9 @@ class NonGodPotEffectDisplay { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return - if (lastTick + 1_000 > System.currentTimeMillis()) return - lastTick = System.currentTimeMillis() + if (!event.isMod(20)) return update() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt index 33f9bf219..e6f118a15 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt @@ -1,16 +1,16 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.OSUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import org.lwjgl.input.Keyboard class PasteIntoSigns { @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.onHypixel) return if (!SkyHanniMod.feature.misc.pasteIntoSigns) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt index f8e0eef47..3763881d7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt @@ -52,7 +52,7 @@ class PatcherSendCoordinates { } @SubscribeEvent - fun onEnterWaypoint(event: LorenzTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!event.isMod(10)) return val location = LocationUtils.playerLocation() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/QuickModMenuSwitch.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/QuickModMenuSwitch.kt index 6d97d5a74..b4a0ec53f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/QuickModMenuSwitch.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/QuickModMenuSwitch.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.test.command.CopyErrorCommand import at.hannibal2.skyhanni.utils.LorenzUtils @@ -13,12 +14,10 @@ import net.minecraft.client.renderer.GlStateManager import net.minecraftforge.client.ClientCommandHandler import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent object QuickModMenuSwitch { private val config get() = SkyHanniMod.feature.misc.quickModMenuSwitch private var display = emptyList<List<Any>>() - private var tick = 0 private var latestGuiPath = "" private var mods: List<Mod>? = null @@ -44,10 +43,10 @@ object QuickModMenuSwitch { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return - if (tick++ % 5 == 0) { + if (event.isMod(5)) { update() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt index 6568e9234..fd392c876 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt @@ -3,26 +3,22 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.data.TitleUtils +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.TimeUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class ServerRestartTitle { private val config get() = SkyHanniMod.feature.misc - private var tick = 0 private val pattern = "§cServer closing: (?<minutes>\\d+):(?<seconds>\\d+) §8.*".toPattern() @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.inSkyBlock) return if (!config.serverRestartTitle) return - if (event.phase != TickEvent.Phase.START) return - tick++ - - if (tick % 20 != 0) return + if (!event.isMod(20)) return for (line in ScoreboardData.sidebarLinesFormatted) { pattern.matchMatcher(line) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ThunderSparksHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ThunderSparksHighlight.kt index 7b6e2887b..577088c13 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ThunderSparksHighlight.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ThunderSparksHighlight.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.* @@ -12,7 +13,6 @@ import net.minecraft.entity.item.EntityArmorStand import net.minecraft.init.Blocks import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import java.awt.Color class ThunderSparksHighlight { @@ -22,7 +22,7 @@ class ThunderSparksHighlight { private val sparks = mutableListOf<EntityArmorStand>() @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt index bf23419bf..82e40ced3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.SkyHanniMod.Companion.consoleLog import at.hannibal2.skyhanni.SkyHanniMod.Companion.coroutineScope import at.hannibal2.skyhanni.SkyHanniMod.Companion.feature import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.onToggle @@ -15,7 +16,6 @@ import com.jagrosh.discordipc.IPCListener import com.jagrosh.discordipc.entities.RichPresence import kotlinx.coroutines.launch import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import net.minecraftforge.fml.common.network.FMLNetworkEvent import java.util.* import java.util.concurrent.Executors @@ -151,7 +151,7 @@ object DiscordRPCManager : IPCListener { private fun isEnabled() = config.enabled.get() @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (startOnce || !isEnabled()) return // the mod has already started the connection process. this variable is my way of running a function when the player joins skyblock but only running it again once they join and leave. if (LorenzUtils.inSkyBlock) { start() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/tiarelay/TiaRelayHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/tiarelay/TiaRelayHelper.kt index 64b54d9e6..9d5b1e902 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/tiarelay/TiaRelayHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/tiarelay/TiaRelayHelper.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.misc.tiarelay import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.PlaySoundEvent import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent import at.hannibal2.skyhanni.utils.InventoryUtils @@ -9,11 +10,8 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.sorted import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class TiaRelayHelper { - - private var tick = 0 private var inInventory = false private var lastClickSlot = 0 @@ -52,14 +50,11 @@ class TiaRelayHelper { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return + fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.inSkyBlock) return if (!SkyHanniMod.feature.misc.tiaRelayHelper) return - tick++ - - if (tick % 20 == 0) { + if (event.isMod(20)) { if (InventoryUtils.openInventoryName().contains("Network Relay")) { inInventory = true } else { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt index f73f2a406..8a16a83b9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt @@ -4,10 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.data.TitleUtils -import at.hannibal2.skyhanni.events.CheckRenderEntityEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.withAlpha +import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled @@ -27,7 +24,6 @@ import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import org.lwjgl.input.Keyboard import kotlin.concurrent.fixedRateTimer @@ -193,7 +189,7 @@ class TrevorFeatures { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!config.warpToTrapper) return if (!onFarmingIsland()) return if (!Keyboard.getEventKeyState()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt index 6da0ce94b..ec0c13ea0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.misc.update import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.features.About import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.onToggle @@ -12,7 +13,6 @@ import moe.nea.libautoupdate.* import net.minecraft.client.Minecraft import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import java.util.concurrent.CompletableFuture object UpdateManager { @@ -41,8 +41,8 @@ object UpdateManager { } @SubscribeEvent - fun onPlayerAvailableOnce(event: TickEvent.ClientTickEvent) { - val p = Minecraft.getMinecraft().thePlayer ?: return + fun onTick(event: LorenzTickEvent) { + Minecraft.getMinecraft().thePlayer ?: return MinecraftForge.EVENT_BUS.unregister(this) if (config.autoUpdates) checkUpdate() diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt index 73e774f81..14ed0e2ff 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt @@ -14,7 +14,6 @@ import net.minecraft.entity.monster.EntityBlaze import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class AshfangBlazes { @@ -22,13 +21,12 @@ class AshfangBlazes { private val blazeArmorStand = mutableMapOf<EntityBlaze, EntityArmorStand>() var nearAshfang = false - var tick = 0 @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return - if (tick++ % 20 == 0) { + if (event.isMod(20)) { checkNearAshfang() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazingSouls.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazingSouls.kt index 76bf8a1c8..c9f585828 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazingSouls.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazingSouls.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.nether.ashfang import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.features.damageindicator.BossType import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager @@ -11,7 +12,6 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawString import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import java.awt.Color class AshfangBlazingSouls { @@ -21,7 +21,7 @@ class AshfangBlazingSouls { private val souls = mutableListOf<EntityArmorStand>() @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return EntityUtils.getEntities<EntityArmorStand>() diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt index 70328e12b..92b699845 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.nether.ashfang import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.features.damageindicator.BossType import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager @@ -10,7 +11,6 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawString import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import java.awt.Color class AshfangGravityOrbs { @@ -20,7 +20,7 @@ class AshfangGravityOrbs { private val orbs = mutableListOf<EntityArmorStand>() @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return EntityUtils.getEntities<EntityArmorStand>() diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideParticles.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideParticles.kt index 03211eb5b..dc4ff43d7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideParticles.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideParticles.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.nether.ashfang import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.CheckRenderEntityEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.features.damageindicator.BossType import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager @@ -10,18 +11,15 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class AshfangHideParticles { - - var tick = 0 private var nearAshfang = false @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.inSkyBlock) return - if (tick++ % 60 == 0) { + if (event.isMod(60)) { nearAshfang = DamageIndicatorManager.getDistanceTo(BossType.NETHER_ASHFANG) < 40 } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt index c2290a0f2..47eb05f18 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.nether.ashfang import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.features.damageindicator.BossType import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager @@ -12,14 +13,13 @@ import at.hannibal2.skyhanni.utils.TimeUnit import at.hannibal2.skyhanni.utils.TimeUtils import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent class AshfangNextResetCooldown { private var spawnTime = 1L @SubscribeEvent - fun renderOverlay(event: ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return if (EntityUtils.getEntities<EntityArmorStand>().any { diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt index a23623a82..579c6858b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.nether.reputationhelper.dailykuudra.DailyKuudraBossHelper import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.DailyQuestHelper @@ -17,7 +18,6 @@ import at.hannibal2.skyhanni.utils.TabListData import com.google.gson.JsonObject import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { @@ -30,7 +30,6 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { private var display = emptyList<List<Any>>() private var dirty = true - private var tick = 0 init { skyHanniMod.loadModule(questHelper) @@ -60,7 +59,7 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.inSkyBlock) return if (LorenzUtils.skyBlockIsland != IslandType.CRIMSON_ISLE) return if (!SkyHanniMod.feature.misc.crimsonIsleReputationHelper) return @@ -69,8 +68,7 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { updateRender() } - tick++ - if (tick % 60 == 0) { + if (event.isMod(60)) { TabListData.getTabList() .filter { it.contains("Reputation:") } .forEach { diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt index c686ede33..048210679 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt @@ -21,14 +21,12 @@ import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { private val townBoardMage = LorenzVec(-138, 92, -755) private val townBoardBarbarian = LorenzVec(-572, 100, -687) - private var tick = 0 private val questLoader = QuestLoader(this) val quests = mutableListOf<Quest>() private val sacksCache = mutableMapOf<String, Long>() @@ -50,15 +48,14 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return - tick++ - if (tick % 20 == 0) { + if (event.isMod(20)) { checkInventoryForTrophyFish() } - if (tick % 60 == 0) { + if (event.isMod(60)) { checkInventoryForFetchItem() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt index 0deb4fdea..2cb9bf05c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.data.SlayerAPI import at.hannibal2.skyhanni.data.TitleUtils import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzUtils @@ -14,7 +15,6 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.getLorenzVec import net.minecraft.entity.EntityLivingBase import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class SlayerQuestWarning { private val config get() = SkyHanniMod.feature.slayer @@ -22,7 +22,6 @@ class SlayerQuestWarning { private var lastWarning = 0L private var currentReason = "" private var dirtySidebar = false - private var tick = 0 private var activeSlayer: SlayerType? = null //TODO add check if player has clicked on an item, before mobs around you gets damage @@ -63,11 +62,11 @@ class SlayerQuestWarning { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!(LorenzUtils.inSkyBlock)) return if (dirtySidebar) { - if (tick++ % 60 == 0) { + if (event.isMod(60)) { checkSidebar() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt index 1d41aaeeb..ba56b561f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt @@ -5,10 +5,7 @@ import at.hannibal2.skyhanni.config.Storage import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.SlayerAPI import at.hannibal2.skyhanni.data.TitleUtils -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.InventoryOpenEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.SlayerChangeEvent +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.nameWithEnchantment @@ -21,7 +18,6 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.StringUtils.removeWordsAtEnd import io.github.moulberry.notenoughupdates.util.Constants import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import kotlin.math.ceil class SlayerRngMeterDisplay { @@ -32,16 +28,11 @@ class SlayerRngMeterDisplay { private val changedItemPattern = "§aYou set your §r.* RNG Meter §r§ato drop §r.*§a!".toPattern() private var lastItemDroppedTime = 0L - private var tick = 0 - @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return - + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return - tick++ - if (tick % 20 == 0) { + if (event.isMod(20)) { if (lastItemDroppedTime != 0L) { if (System.currentTimeMillis() > lastItemDroppedTime + 4_000) { lastItemDroppedTime = 0L diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt index 6316361fb..1a4a6c70f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt @@ -2,23 +2,21 @@ package at.hannibal2.skyhanni.features.slayer.blaze import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.CheckRenderEntityEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.features.damageindicator.BossType import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.projectile.EntityFireball import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class BlazeSlayerClearView { - - private var tick = 0 private var nearBlaze = false @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.inSkyBlock) return - if (tick++ % 60 == 0) { + if (event.isMod(60)) { nearBlaze = DamageIndicatorManager.getDistanceTo( BossType.SLAYER_BLAZE_1, BossType.SLAYER_BLAZE_2, diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt index 503975822..632433573 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt @@ -2,10 +2,7 @@ package at.hannibal2.skyhanni.features.slayer.blaze import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ClickType -import at.hannibal2.skyhanni.events.BlockClickEvent -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.TitleReceivedEvent +import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LocationUtils @@ -19,7 +16,6 @@ import net.minecraft.client.gui.ScaledResolution import net.minecraft.client.renderer.GlStateManager import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class BlazeSlayerDaggerHelper { @@ -47,7 +43,7 @@ class BlazeSlayerDaggerHelper { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return val player = Minecraft.getMinecraft().thePlayer diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt index ff5558d80..9d61e1393 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt @@ -3,20 +3,19 @@ package at.hannibal2.skyhanni.features.slayer.blaze import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.TitleUtils import at.hannibal2.skyhanni.events.BossHealthChangeEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.damageindicator.BossType import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.SoundUtils.playSound import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class BlazeSlayerFirePitsWarning { private val config get() = SkyHanniMod.feature.slayer companion object { private var lastFirePitsWarning = 0L - private var nextTickIn = 0 fun fireFirePits() { TitleUtils.sendTitle("§cFire Pits!", 2_000) @@ -24,14 +23,14 @@ class BlazeSlayerFirePitsWarning { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return val difference = System.currentTimeMillis() - lastFirePitsWarning if (difference > 0) { if (difference <= 2_000) { - if (nextTickIn++ % 10 == 0) { + if (event.isMod(10)) { if (config.firePitsWarning) { SoundUtils.createSound("random.orb", 0.8f).playSound() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt index faac1563b..56f490e9b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt @@ -12,7 +12,6 @@ import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class SummoningMobManager { @@ -61,14 +60,12 @@ class SummoningMobManager { } } - var tick = 0 - @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return if (SkyHanniMod.feature.summonings.summoningMobDisplay) { - if (tick++ % 20 == 0) { + if (event.isMod(20)) { updateData() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningSoulsName.kt b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningSoulsName.kt index aeb434170..5bf3b1a3d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningSoulsName.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningSoulsName.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.summonings import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.EntityUtils.getNameTagWith @@ -15,7 +16,6 @@ import net.minecraft.entity.EntityLiving import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent class SummoningSoulsName { @@ -31,7 +31,7 @@ class SummoningSoulsName { private val mobsName = mutableMapOf<EntityLiving, String>() @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return //TODO use packets instead of this diff --git a/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt b/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt index 1020a5a9c..e7d229ca8 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.test import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.RenderUtils.drawFilledBoundingBox import at.hannibal2.skyhanni.utils.RenderUtils.expandBlock @@ -10,7 +11,6 @@ import net.minecraft.client.gui.inventory.GuiEditSign import net.minecraft.client.gui.inventory.GuiInventory import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import org.lwjgl.input.Keyboard class ParkourWaypointSaver { @@ -20,7 +20,7 @@ class ParkourWaypointSaver { private var parkourHelper: ParkourHelper? = null @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.inSkyBlock) return if (!Keyboard.getEventKeyState()) return if (NEUItems.neuHasFocus()) return diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TabListData.kt b/src/main/java/at/hannibal2/skyhanni/utils/TabListData.kt index c1eb9a265..131b73491 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/TabListData.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/TabListData.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.utils +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.mixins.hooks.tabListGuard import com.google.common.collect.ComparisonChain @@ -8,7 +9,6 @@ import net.minecraft.client.Minecraft import net.minecraft.client.network.NetworkPlayerInfo import net.minecraft.world.WorldSettings import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent import net.minecraftforge.fml.relauncher.Side import net.minecraftforge.fml.relauncher.SideOnly import java.util.* @@ -57,8 +57,7 @@ class TabListData { private var ticks = 0 @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (event.phase != TickEvent.Phase.START) return + fun onTick(event: LorenzTickEvent) { if (ticks++ % 5 != 0) return |