diff --git a/src/main/kotlin/gg/skytils/skytilsmod/Skytils.kt b/src/main/kotlin/gg/skytils/skytilsmod/Skytils.kt index 6eca58cf4..398fa96da 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/Skytils.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/Skytils.kt @@ -556,7 +556,7 @@ class Skytils { val old = mc.currentScreen if (event.gui == null && config.reopenOptionsMenu) { if (old is ReopenableGUI || (old is AccessorSettingsGui && old.config is Config)) { - TickTask(1) { + tickTimer(1) { if (mc.thePlayer?.openContainer == mc.thePlayer?.inventoryContainer) displayScreen = OptionsGui() } diff --git a/src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt b/src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt index 841117ea4..974cdac0f 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt @@ -2960,7 +2960,7 @@ object Config : Vigilant( addDependency("assumeWitherImpact", "witherShieldCooldown") registerListener("protectItemBINThreshold") { _: String -> - TickTask(1) { + tickTimer(1) { val numeric = protectItemBINThreshold.replace(Regex("[^0-9]"), "") protectItemBINThreshold = numeric.ifEmpty { "0" } if (protectItemBINThreshold != "0") fetchLowestBINPrices = true @@ -2978,7 +2978,7 @@ object Config : Vigilant( val loc = ResourceLocation("skytils:gui/customrarity.png") mc.resourceManager.getResource(loc) }.onFailure { - TickTask(1) { + tickTimer(1) { if (itemRarityShape == 4) { itemRarityShape = old EssentialAPI.getNotifications() diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/BloodHelper.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/BloodHelper.kt index a4105339b..a0fa5ebc0 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/BloodHelper.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/BloodHelper.kt @@ -21,7 +21,7 @@ package gg.skytils.skytilsmod.features.impl.dungeons import gg.essential.universal.UMatrixStack import gg.essential.universal.UMinecraft import gg.skytils.skytilsmod.Skytils -import gg.skytils.skytilsmod.core.TickTask +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.events.impl.MainReceivePacketEvent import gg.skytils.skytilsmod.utils.ItemUtil import gg.skytils.skytilsmod.utils.RenderUtil @@ -113,11 +113,11 @@ object BloodHelper { fun onJoin(event: EntityJoinWorldEvent) { if (event.entity !is EntityZombie) return (event.entity as EntityZombie).apply { - TickTask(1) { + tickTimer(1) { val helmet = getEquipmentInSlot(4) - if (helmet == null || helmet.item != Items.skull) return@TickTask + if (helmet == null || helmet.item != Items.skull) return@tickTimer val texture = ItemUtil.getSkullTexture(helmet) - if (texture == null || (watcherSkins.contains(texture))) return@TickTask + if (texture == null || (watcherSkins.contains(texture))) return@tickTimer printDevMessage("found watcher", "blood") watchers.add(this) } diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/DungeonTimer.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/DungeonTimer.kt index b6308ed04..051ca18ab 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/DungeonTimer.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/DungeonTimer.kt @@ -19,8 +19,8 @@ package gg.skytils.skytilsmod.features.impl.dungeons import gg.essential.universal.UChat import gg.skytils.skytilsmod.Skytils -import gg.skytils.skytilsmod.core.TickTask import gg.skytils.skytilsmod.core.structure.GuiElement +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.listeners.DungeonListener import gg.skytils.skytilsmod.utils.NumberUtil import gg.skytils.skytilsmod.utils.NumberUtil.roundToPrecision @@ -110,7 +110,7 @@ object DungeonTimer { bossEntryTime != -1L && bossClearTime == -1L && message.contains("§r§c☠ §r§eDefeated §r") -> { bossClearTime = System.currentTimeMillis() - TickTask(5) { + tickTimer(5) { arrayListOf().apply { if (Skytils.config.dungeonTimer) { add("§7Wither Doors: $witherDoors") diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/MasterMode7Features.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/MasterMode7Features.kt index 2ba345a76..9e0a0d668 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/MasterMode7Features.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/MasterMode7Features.kt @@ -24,7 +24,7 @@ import gg.essential.universal.UMatrixStack import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.Skytils.Companion.mc import gg.skytils.skytilsmod.core.GuiManager -import gg.skytils.skytilsmod.core.TickTask +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.events.impl.BlockChangeEvent import gg.skytils.skytilsmod.events.impl.CheckRenderEntityEvent import gg.skytils.skytilsmod.events.impl.MainReceivePacketEvent @@ -76,8 +76,8 @@ object MasterMode7Features { } init { - TickTask(15, repeats = true) { - if (DungeonTimer.phase4ClearTime == -1L || DungeonTimer.scoreShownAt != -1L || mc.thePlayer == null) return@TickTask + tickTimer(15, repeats = true) { + if (DungeonTimer.phase4ClearTime == -1L || DungeonTimer.scoreShownAt != -1L || mc.thePlayer == null) return@tickTimer if (Skytils.config.witherKingDragonSlashAlert) { if (glowstones.any { it.isVecInside(mc.thePlayer.positionVector) }) { GuiManager.createTitle("Dimensional Slash!", 10) diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/ScoreCalculation.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/ScoreCalculation.kt index fa76c3c30..1ef4de086 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/ScoreCalculation.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/ScoreCalculation.kt @@ -22,8 +22,8 @@ import gg.essential.elementa.state.State import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.Skytils.Companion.mc import gg.skytils.skytilsmod.core.GuiManager -import gg.skytils.skytilsmod.core.TickTask import gg.skytils.skytilsmod.core.structure.GuiElement +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.events.impl.MainReceivePacketEvent import gg.skytils.skytilsmod.features.impl.handlers.MayorInfo import gg.skytils.skytilsmod.listeners.DungeonListener @@ -422,7 +422,7 @@ object ScoreCalculation { } init { - TickTask(5, repeats = true) { + tickTimer(5, repeats = true) { isPaul.set( (MayorInfo.currentMayor == "Paul" && MayorInfo.mayorPerks.contains("EZPZ")) || MayorInfo.jerryMayor?.name == "Paul" ) diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/BlazeSolver.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/BlazeSolver.kt index 653280997..771aab3aa 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/BlazeSolver.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/BlazeSolver.kt @@ -22,7 +22,7 @@ import gg.essential.universal.UMatrixStack import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.Skytils.Companion.failPrefix import gg.skytils.skytilsmod.Skytils.Companion.mc -import gg.skytils.skytilsmod.core.TickTask +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.events.impl.skyblock.DungeonEvent import gg.skytils.skytilsmod.listeners.DungeonListener import gg.skytils.skytilsmod.utils.RenderUtil @@ -51,7 +51,7 @@ object BlazeSolver { var lastKilledBlazeHp = 0 init { - TickTask(4, repeats = true) { + tickTimer(4, repeats = true) { if (Skytils.config.blazeSolver && Utils.inDungeons && DungeonListener.missingPuzzles.contains( "Higher Or Lower" ) @@ -59,7 +59,7 @@ object BlazeSolver { calcOrder() } } - TickTask(20, repeats = true) { + tickTimer(20, repeats = true) { if (Skytils.config.blazeSolver && Utils.inDungeons && DungeonListener.missingPuzzles.contains( "Higher Or Lower" ) diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/BoulderSolver.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/BoulderSolver.kt index 6f6407b06..6a986e041 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/BoulderSolver.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/BoulderSolver.kt @@ -23,7 +23,7 @@ import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.Skytils.Companion.failPrefix import gg.skytils.skytilsmod.Skytils.Companion.mc import gg.skytils.skytilsmod.Skytils.Companion.successPrefix -import gg.skytils.skytilsmod.core.TickTask +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.events.impl.skyblock.DungeonEvent import gg.skytils.skytilsmod.listeners.DungeonListener import gg.skytils.skytilsmod.utils.RenderUtil @@ -55,7 +55,7 @@ object BoulderSolver { private var job: Job? = null init { - TickTask(20, repeats = true, task = ::update) + tickTimer(20, repeats = true, task = ::update) } @SubscribeEvent diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/CreeperSolver.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/CreeperSolver.kt index ff8a897a9..0ce1828b5 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/CreeperSolver.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/CreeperSolver.kt @@ -20,7 +20,7 @@ package gg.skytils.skytilsmod.features.impl.dungeons.solvers import gg.essential.universal.UMatrixStack import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.Skytils.Companion.mc -import gg.skytils.skytilsmod.core.TickTask +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.events.impl.skyblock.DungeonEvent import gg.skytils.skytilsmod.listeners.DungeonListener import gg.skytils.skytilsmod.utils.* @@ -89,7 +89,7 @@ object CreeperSolver { } init { - TickTask(20, repeats = true) { + tickTimer(20, repeats = true) { if (Skytils.config.creeperBeamsSolver && Utils.inDungeons && DungeonListener.missingPuzzles.contains( "Creeper Beams" ) diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/IceFillSolver.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/IceFillSolver.kt index 81508313d..ecc135e20 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/IceFillSolver.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/IceFillSolver.kt @@ -20,7 +20,7 @@ package gg.skytils.skytilsmod.features.impl.dungeons.solvers import gg.essential.universal.UMatrixStack import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.Skytils.Companion.mc -import gg.skytils.skytilsmod.core.TickTask +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.features.impl.misc.Funny import gg.skytils.skytilsmod.listeners.DungeonListener import gg.skytils.skytilsmod.utils.RenderUtil @@ -48,8 +48,8 @@ object IceFillSolver { private var job: Job? = null init { - TickTask(20, repeats = true) { - if (!Utils.inDungeons || !Skytils.config.iceFillSolver || mc.thePlayer == null) return@TickTask + tickTimer(20, repeats = true) { + if (!Utils.inDungeons || !Skytils.config.iceFillSolver || mc.thePlayer == null) return@tickTimer val world: World = mc.theWorld if (DungeonListener.missingPuzzles.contains("Ice Fill") && (job == null || job?.isCancelled == true || job?.isCompleted == true)) { if (chestPos == null || roomFacing == null) { diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/IcePathSolver.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/IcePathSolver.kt index 0e25c06bd..3fcad56a6 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/IcePathSolver.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/IcePathSolver.kt @@ -20,7 +20,7 @@ package gg.skytils.skytilsmod.features.impl.dungeons.solvers import gg.essential.universal.UMatrixStack import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.Skytils.Companion.mc -import gg.skytils.skytilsmod.core.TickTask +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.features.impl.misc.Funny import gg.skytils.skytilsmod.listeners.DungeonListener import gg.skytils.skytilsmod.utils.RenderUtil @@ -49,8 +49,8 @@ object IcePathSolver { private var silverfishPos: Point? = null init { - TickTask(20, repeats = true) { - if (!Utils.inDungeons || !Skytils.config.icePathSolver || mc.thePlayer == null) return@TickTask + tickTimer(20, repeats = true) { + if (!Utils.inDungeons || !Skytils.config.icePathSolver || mc.thePlayer == null) return@tickTimer if (DungeonListener.missingPuzzles.contains("Ice Path")) { val silverfish = mc.theWorld.getEntities( EntitySilverfish::class.java diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/TicTacToeSolver.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/TicTacToeSolver.kt index 1f8418fe4..6f0fa6af6 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/TicTacToeSolver.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/TicTacToeSolver.kt @@ -20,7 +20,7 @@ package gg.skytils.skytilsmod.features.impl.dungeons.solvers import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.Skytils.Companion.mc -import gg.skytils.skytilsmod.core.TickTask +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.events.impl.skyblock.DungeonEvent import gg.skytils.skytilsmod.listeners.DungeonListener import gg.skytils.skytilsmod.utils.RenderUtil @@ -48,8 +48,8 @@ object TicTacToeSolver { private var bestMove: BlockPos? = null init { - TickTask(20, repeats = true) { - if (!Utils.inDungeons || !Skytils.config.ticTacToeSolver || mc.thePlayer == null) return@TickTask + tickTimer(20, repeats = true) { + if (!Utils.inDungeons || !Skytils.config.ticTacToeSolver || mc.thePlayer == null) return@tickTimer if (SuperSecretSettings.azooPuzzoo || DungeonListener.missingPuzzles.contains("Tic Tac Toe")) { updatePuzzleState() } else { diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/WaterBoardSolver.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/WaterBoardSolver.kt index 81e5fcab9..ad5bd95fd 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/WaterBoardSolver.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/WaterBoardSolver.kt @@ -20,7 +20,7 @@ package gg.skytils.skytilsmod.features.impl.dungeons.solvers import gg.essential.universal.UMatrixStack import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.Skytils.Companion.mc -import gg.skytils.skytilsmod.core.TickTask +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.listeners.DungeonListener import gg.skytils.skytilsmod.utils.RenderUtil import gg.skytils.skytilsmod.utils.SuperSecretSettings @@ -58,10 +58,10 @@ object WaterBoardSolver { private var job: Job? = null init { - TickTask(20, repeats = true) { - if (!Skytils.config.waterBoardSolver || !Utils.inDungeons) return@TickTask - val player = mc.thePlayer ?: return@TickTask - val world = mc.theWorld ?: return@TickTask + tickTimer(20, repeats = true) { + if (!Skytils.config.waterBoardSolver || !Utils.inDungeons) return@tickTimer + val player = mc.thePlayer ?: return@tickTimer + val world = mc.theWorld ?: return@tickTimer if (DungeonListener.missingPuzzles.contains("Water Board") && variant == -1 && (job == null || job?.isCancelled == true || job?.isCompleted == true)) { job = Skytils.launch { prevInWaterRoom = inWaterRoom diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/terminals/AlignmentTaskSolver.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/terminals/AlignmentTaskSolver.kt index b421fe09d..adc80e9a8 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/terminals/AlignmentTaskSolver.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/dungeons/solvers/terminals/AlignmentTaskSolver.kt @@ -21,7 +21,7 @@ package gg.skytils.skytilsmod.features.impl.dungeons.solvers.terminals import gg.essential.universal.UMatrixStack import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.Skytils.Companion.mc -import gg.skytils.skytilsmod.core.TickTask +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.features.impl.dungeons.DungeonFeatures import gg.skytils.skytilsmod.features.impl.dungeons.DungeonTimer import gg.skytils.skytilsmod.utils.RenderUtil @@ -61,12 +61,12 @@ object AlignmentTaskSolver { private val directionSet = HashMap() init { - TickTask(20, repeats = true) { + tickTimer(20, repeats = true) { if (!Skytils.config.alignmentTerminalSolver || !Utils.inDungeons || mc.thePlayer == null || (!SuperSecretSettings.azooPuzzoo && (DungeonTimer.phase2ClearTime == -1L || DungeonTimer.phase3ClearTime != -1L) || !Utils.equalsOneOf( DungeonFeatures.dungeonFloor, "F7", "M7" )) - ) return@TickTask + ) return@tickTimer if (mc.thePlayer.getDistanceSqToCenter(topLeft) <= 25 * 25) { if (grid.size < 25) { val frames = mc.theWorld.getEntities(EntityItemFrame::class.java) { diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/farming/FarmingFeatures.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/farming/FarmingFeatures.kt index 47e5574ef..7ac2c3d5f 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/farming/FarmingFeatures.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/farming/FarmingFeatures.kt @@ -25,7 +25,7 @@ import gg.skytils.skytilsmod.Skytils.Companion.prefix import gg.skytils.skytilsmod.Skytils.Companion.successPrefix import gg.skytils.skytilsmod.core.DataFetcher import gg.skytils.skytilsmod.core.SoundQueue -import gg.skytils.skytilsmod.core.TickTask +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.events.impl.PacketEvent.ReceiveEvent import gg.skytils.skytilsmod.features.impl.handlers.MayorInfo import gg.skytils.skytilsmod.utils.SBInfo @@ -122,7 +122,7 @@ object FarmingFeatures { val solution = hungerHikerItems.getOrDefault(hungerHikerItems.keys.find { s: String -> unformatted.contains(s) }, null) - TickTask(4) { + tickTimer(4) { if (solution != null) { UChat.chat("$successPrefix §aThe Hiker needs: §l§2 $solution§a!") } else { diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/farming/GardenFeatures.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/farming/GardenFeatures.kt index 0f5b9f77e..18d9d4180 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/farming/GardenFeatures.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/farming/GardenFeatures.kt @@ -21,7 +21,7 @@ package gg.skytils.skytilsmod.features.impl.farming import gg.essential.api.EssentialAPI import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.Skytils.Companion.mc -import gg.skytils.skytilsmod.core.TickTask +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.utils.* import net.minecraft.init.Blocks import net.minecraft.util.BlockPos @@ -72,7 +72,7 @@ object GardenFeatures { } init { - TickTask(5, repeats = true) { + tickTimer(5, repeats = true) { if (mc.thePlayer != null) { val inGarden = SBInfo.mode == SkyblockIsland.TheGarden.mode diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/farming/VisitorHelper.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/farming/VisitorHelper.kt index 4c47e3cd8..dd0e59136 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/farming/VisitorHelper.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/farming/VisitorHelper.kt @@ -22,8 +22,8 @@ import gg.essential.universal.UMatrixStack import gg.essential.universal.UResolution import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.Skytils.Companion.mc -import gg.skytils.skytilsmod.core.TickTask import gg.skytils.skytilsmod.core.structure.GuiElement +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.events.impl.GuiContainerEvent import gg.skytils.skytilsmod.features.impl.handlers.AuctionData import gg.skytils.skytilsmod.features.impl.misc.ContainerSellValue @@ -55,15 +55,15 @@ object VisitorHelper { } init { - TickTask(4, repeats = true) { - if (!Skytils.config.visitorOfferHelper) return@TickTask + tickTimer(4, repeats = true) { + if (!Skytils.config.visitorOfferHelper) return@tickTimer textLines.clear() totalItemCost = 0.0 - if (!inGarden) return@TickTask + if (!inGarden) return@tickTimer - val container = (mc.currentScreen as? GuiChest)?.inventorySlots as? ContainerChest ?: return@TickTask + val container = (mc.currentScreen as? GuiChest)?.inventorySlots as? ContainerChest ?: return@tickTimer val chestName = container.lowerChestInventory.name val npcSummary: ItemStack? = container.getSlot(13).stack val acceptOffer: ItemStack? = container.getSlot(29).stack @@ -75,7 +75,7 @@ object VisitorHelper { textLines.add("§eRewards:") val rewardIndex = lore.indexOf("§7Rewards:") - if (rewardIndex == -1) return@TickTask + if (rewardIndex == -1) return@tickTimer lore.drop(rewardIndex + 1) .takeWhile { it != "" } diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/handlers/MayorInfo.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/handlers/MayorInfo.kt index 545c8b5a8..07c083dc5 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/handlers/MayorInfo.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/handlers/MayorInfo.kt @@ -23,7 +23,7 @@ import gg.skytils.skytilsmod.Skytils.Companion.client import gg.skytils.skytilsmod.Skytils.Companion.json import gg.skytils.skytilsmod.Skytils.Companion.mc import gg.skytils.skytilsmod.core.SoundQueue -import gg.skytils.skytilsmod.core.TickTask +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.events.impl.GuiContainerEvent import gg.skytils.skytilsmod.utils.* import io.ktor.client.call.* @@ -61,10 +61,10 @@ object MayorInfo { private val jerryNextPerkRegex = Regex("§7Next set of perks in §e(?\\d+?)h (?\\d+?)m") init { - TickTask(60 * 20, repeats = true) { + tickTimer(60 * 20, repeats = true) { if (!Utils.inSkyblock || mc.currentServerData?.serverIP?.lowercase() ?.contains("alpha") == true - ) return@TickTask + ) return@tickTimer if (currentMayor == "Jerry" && System.currentTimeMillis() > newJerryPerks) { if (jerryMayor != null && Skytils.config.displayJerryPerks) { SoundQueue.addToQueue("random.orb", 0.8f, 1f, 1, true) @@ -134,7 +134,7 @@ object MayorInfo { fun fetchMayorData() = Skytils.IO.launch { val res = json.decodeFromJsonElement(client.get("https://api.hypixel.net/resources/skyblock/election").body()["mayor"]!!) - TickTask(1) { + tickTimer(1) { currentMayor = res.name lastFetchedMayorData = System.currentTimeMillis() if (currentMayor != "Jerry") jerryMayor = null @@ -145,7 +145,7 @@ object MayorInfo { fun fetchJerryData() = Skytils.IO.launch { val res = client.get("https://${Skytils.domain}/api/mayor").body() - TickTask(1) { + tickTimer(1) { newJerryPerks = res.nextSwitch jerryMayor = res.mayor } diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/handlers/PotionEffectTimers.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/handlers/PotionEffectTimers.kt index 6fa9c2722..86e15ba65 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/handlers/PotionEffectTimers.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/handlers/PotionEffectTimers.kt @@ -25,7 +25,7 @@ import gg.essential.universal.wrappers.message.UTextComponent import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.core.GuiManager import gg.skytils.skytilsmod.core.PersistentSave -import gg.skytils.skytilsmod.core.TickTask +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.events.impl.GuiContainerEvent import gg.skytils.skytilsmod.events.impl.PacketEvent import gg.skytils.skytilsmod.events.impl.SendChatMessageEvent @@ -65,7 +65,7 @@ object PotionEffectTimers : PersistentSave(File(Skytils.modDir, "potionEffectTim is S02PacketChat -> { val message = event.packet.chatComponent.formattedText if (message.startsWithAny("§a§lBUFF! §f", "§r§aYou ate ")) { - TickTask(1) { + tickTimer(1) { UMessage( UTextComponent("${Skytils.prefix} §fYour potion effects have been updated! Click me to update your effect timers.").setClick( MCClickEventAction.RUN_COMMAND, @@ -145,7 +145,7 @@ object PotionEffectTimers : PersistentSave(File(Skytils.modDir, "potionEffectTim if (currPage != neededPage) return if (item.item == Items.arrow && item.displayName == "§aNext Page") { neededPage++ - TickTask(20) { + tickTimer(20) { UChat.chat("${Skytils.prefix} §fMoving to the next page ${neededPage}... Don't close your inventory!") mc.playerController.windowClick( event.container.windowId, @@ -157,7 +157,7 @@ object PotionEffectTimers : PersistentSave(File(Skytils.modDir, "potionEffectTim } } else { shouldReadEffects = false - TickTask(20) { + tickTimer(20) { mc.thePlayer.closeScreen() UChat.chat("${Skytils.successPrefix} §aYour ${potionEffectTimers.size} potion effects have been updated!") } diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/handlers/Waypoints.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/handlers/Waypoints.kt index 2b12e3e34..c7a6a7d19 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/handlers/Waypoints.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/handlers/Waypoints.kt @@ -22,7 +22,7 @@ import gg.essential.universal.UGraphics import gg.essential.universal.UMatrixStack import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.core.PersistentSave -import gg.skytils.skytilsmod.core.TickTask +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.events.impl.skyblock.LocrawReceivedEvent import gg.skytils.skytilsmod.utils.* import kotlinx.serialization.* @@ -139,7 +139,7 @@ object Waypoints : PersistentSave(File(Skytils.modDir, "waypoints.json")) { @SubscribeEvent fun onLocraw(event: LocrawReceivedEvent) { - TickTask(20, task = ::computeVisibleWaypoints) + tickTimer(20, task = ::computeVisibleWaypoints) } @SubscribeEvent diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/mining/MiningFeatures.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/mining/MiningFeatures.kt index d9c9c449e..2a1488a7d 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/mining/MiningFeatures.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/mining/MiningFeatures.kt @@ -31,8 +31,8 @@ import gg.skytils.skytilsmod.Skytils.Companion.successPrefix import gg.skytils.skytilsmod.core.DataFetcher import gg.skytils.skytilsmod.core.GuiManager import gg.skytils.skytilsmod.core.GuiManager.createTitle -import gg.skytils.skytilsmod.core.TickTask import gg.skytils.skytilsmod.core.structure.GuiElement +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.events.impl.BossBarEvent import gg.skytils.skytilsmod.events.impl.GuiContainerEvent import gg.skytils.skytilsmod.events.impl.PacketEvent @@ -175,7 +175,7 @@ object MiningFeatures { s ) }, null) - TickTask(50) { + tickTimer(50) { if (solution != null) { UChat.chat("$successPrefix §aFetchur needs: §2${solution}§a!") } else { diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/BrewingFeatures.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/BrewingFeatures.kt index 59592e859..a8df19e81 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/BrewingFeatures.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/BrewingFeatures.kt @@ -21,7 +21,7 @@ package gg.skytils.skytilsmod.features.impl.misc import gg.essential.universal.UMatrixStack import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.Skytils.Companion.mc -import gg.skytils.skytilsmod.core.TickTask +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.events.impl.GuiContainerEvent import gg.skytils.skytilsmod.events.impl.PacketEvent import gg.skytils.skytilsmod.utils.* @@ -41,8 +41,8 @@ object BrewingFeatures { private val red = Color(255, 0, 0, 128) init { - TickTask(100, repeats = true) { - if (!Skytils.config.colorBrewingStands || !Utils.inSkyblock || SBInfo.mode != SkyblockIsland.PrivateIsland.mode) return@TickTask + tickTimer(100, repeats = true) { + if (!Skytils.config.colorBrewingStands || !Utils.inSkyblock || SBInfo.mode != SkyblockIsland.PrivateIsland.mode) return@tickTimer brewingStandToTimeMap.entries.removeIf { mc.theWorld?.getTileEntity(it.key) !is TileEntityBrewingStand } diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/ContainerSellValue.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/ContainerSellValue.kt index 0197672ef..9aae12102 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/ContainerSellValue.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/ContainerSellValue.kt @@ -23,8 +23,8 @@ import gg.essential.universal.UMatrixStack import gg.essential.universal.UResolution import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.Skytils.Companion.mc -import gg.skytils.skytilsmod.core.TickTask import gg.skytils.skytilsmod.core.structure.GuiElement +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.events.impl.GuiContainerEvent import gg.skytils.skytilsmod.features.impl.handlers.AuctionData import gg.skytils.skytilsmod.mixins.hooks.item.masterStarPattern @@ -261,14 +261,14 @@ object ContainerSellValue { * Update the list of items in the GUI to be displayed after the container background is drawn. */ init { - TickTask(4, repeats = true) { - if (!Skytils.config.containerSellValue) return@TickTask + tickTimer(4, repeats = true) { + if (!Skytils.config.containerSellValue) return@tickTimer - val container = (mc.currentScreen as? GuiChest)?.inventorySlots as? ContainerChest ?: return@TickTask + val container = (mc.currentScreen as? GuiChest)?.inventorySlots as? ContainerChest ?: return@tickTimer val chestName = container.lowerChestInventory.name - if (!isChestNameValid(chestName)) return@TickTask + if (!isChestNameValid(chestName)) return@tickTimer val isMinion = chestName.contains(" Minion ") @@ -292,7 +292,7 @@ object ContainerSellValue { // Sort the items from most to least valuable and convert them into a readable format textLines.clear() - if (distinctItems.isEmpty() || totalContainerValue == 0.0) return@TickTask + if (distinctItems.isEmpty() || totalContainerValue == 0.0) return@tickTimer textLines.addAll( distinctItems.entries.asSequence() .sortedByDescending { (_, displayItem) -> displayItem.lowestBIN } diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/Funny.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/Funny.kt index 3a9e11dc2..7a0a168a1 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/Funny.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/Funny.kt @@ -24,8 +24,8 @@ import gg.essential.universal.wrappers.message.UMessage import gg.essential.universal.wrappers.message.UTextComponent import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.core.GuiManager -import gg.skytils.skytilsmod.core.TickTask import gg.skytils.skytilsmod.core.structure.GuiElement +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.gui.elements.GIFResource import gg.skytils.skytilsmod.utils.SuperSecretSettings import gg.skytils.skytilsmod.utils.Utils @@ -70,7 +70,7 @@ object Funny { if (classification.size != machineLearningModel.size) { Skytils.sendMessageQueue.addFirst("/lobby ptl") - TickTask(10) { + tickTimer(10) { val cheetos = classification - machineLearningModel UChat.chat( diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/ItemFeatures.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/ItemFeatures.kt index 9360e49b9..4f7f07bdd 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/ItemFeatures.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/ItemFeatures.kt @@ -23,8 +23,8 @@ import gg.essential.universal.UResolution import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.Skytils.Companion.mc import gg.skytils.skytilsmod.core.GuiManager -import gg.skytils.skytilsmod.core.TickTask import gg.skytils.skytilsmod.core.structure.GuiElement +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.events.impl.GuiContainerEvent import gg.skytils.skytilsmod.events.impl.GuiContainerEvent.SlotClickEvent import gg.skytils.skytilsmod.events.impl.GuiRenderItemEvent @@ -143,7 +143,7 @@ object ItemFeatures { ) init { - TickTask(4, repeats = true) { + tickTimer(4, repeats = true) { if (mc.thePlayer != null && Utils.inSkyblock) { val held = mc.thePlayer.inventory.getCurrentItem() if (Skytils.config.showItemRarity) { diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/MiscFeatures.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/MiscFeatures.kt index 5171fa355..19d1302ad 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/MiscFeatures.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/MiscFeatures.kt @@ -24,8 +24,8 @@ import gg.skytils.skytilsmod.Skytils.Companion.failPrefix import gg.skytils.skytilsmod.Skytils.Companion.mc import gg.skytils.skytilsmod.Skytils.Companion.prefix import gg.skytils.skytilsmod.core.GuiManager.createTitle -import gg.skytils.skytilsmod.core.TickTask import gg.skytils.skytilsmod.core.structure.GuiElement +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.events.impl.* import gg.skytils.skytilsmod.events.impl.GuiContainerEvent.SlotClickEvent import gg.skytils.skytilsmod.events.impl.PacketEvent.ReceiveEvent @@ -286,7 +286,7 @@ object MiscFeatures { fun onJoin(event: EntityJoinWorldEvent) { if (!Utils.inSkyblock || mc.thePlayer == null || mc.theWorld == null) return if (event.entity is EntityArmorStand) { - TickTask(5) { + tickTimer(5) { val entity = event.entity as EntityArmorStand val headSlot = entity.getCurrentArmor(3) if (Skytils.config.trickOrTreatChestAlert && mc.thePlayer != null && headSlot != null && headSlot.item === Items.skull && headSlot.hasTagCompound() && entity.getDistanceSqToEntity( diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/ScamCheck.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/ScamCheck.kt index 119e06c9a..51ec4d1ab 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/ScamCheck.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/ScamCheck.kt @@ -23,7 +23,7 @@ import gg.essential.universal.wrappers.message.UMessage import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.Skytils.Companion.client import gg.skytils.skytilsmod.Skytils.Companion.mc -import gg.skytils.skytilsmod.core.TickTask +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.events.impl.MainReceivePacketEvent import gg.skytils.skytilsmod.utils.ItemUtil import gg.skytils.skytilsmod.utils.MojangUtil @@ -86,7 +86,7 @@ object ScamCheck { ?: return@launch UChat.chat("${Skytils.failPrefix} §cUnable to get the UUID for ${otherParty}! Could they be nicked?") val result = checkScammer(uuid, "tradewindow") if (result.isScammer) { - TickTask(1) { + tickTimer(1) { mc.thePlayer?.closeScreen() } } diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/SlayerFeatures.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/SlayerFeatures.kt index cdee7d4c9..6967533b9 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/SlayerFeatures.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/misc/SlayerFeatures.kt @@ -25,10 +25,8 @@ import gg.essential.universal.UResolution import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.Skytils.Companion.mc import gg.skytils.skytilsmod.Skytils.Companion.prefix -import gg.skytils.skytilsmod.core.GuiManager +import gg.skytils.skytilsmod.core.* import gg.skytils.skytilsmod.core.GuiManager.createTitle -import gg.skytils.skytilsmod.core.SoundQueue -import gg.skytils.skytilsmod.core.TickTask import gg.skytils.skytilsmod.core.structure.GuiElement import gg.skytils.skytilsmod.events.impl.BlockChangeEvent import gg.skytils.skytilsmod.events.impl.CheckRenderEntityEvent @@ -46,6 +44,7 @@ import gg.skytils.skytilsmod.utils.graphics.ScreenRenderer import gg.skytils.skytilsmod.utils.graphics.SmartFontRenderer import gg.skytils.skytilsmod.utils.graphics.colors.CommonColors import kotlinx.coroutines.* +import kotlinx.coroutines.flow.first import net.minecraft.block.* import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.client.gui.GuiChat @@ -188,7 +187,7 @@ object SlayerFeatures : CoroutineScope { } init { - TickTask(4, repeats = true) { + tickTimer(4, repeats = true) { if (Utils.inSkyblock && Skytils.config.showRNGMeter) { for ((index, line) in sidebarLines.withIndex()) { if (line == "Slayer Quest") { @@ -363,7 +362,7 @@ object SlayerFeatures : CoroutineScope { ) { slayer?.run { launch { - val (n, t) = detectSlayerEntities().await() + val (n, t) = detectSlayerEntities().first() nameEntity = n timerEntity = t } @@ -958,74 +957,67 @@ object SlayerFeatures : CoroutineScope { init { launch { - val (n, t) = detectSlayerEntities().await() + val (n, t) = detectSlayerEntities().first() nameEntity = n timerEntity = t } } fun detectSlayerEntities() = - CompletableDeferred>().apply { - launch { - TickTask(5) { - val nearbyArmorStands = entity.entityWorld.getEntitiesInAABBexcluding( - entity, entity.entityBoundingBox.expand(0.2, 3.0, 0.2) - ) { nearbyEntity: Entity? -> - if (nearbyEntity is EntityArmorStand) { - if (nearbyEntity.isInvisible && nearbyEntity.hasCustomName()) { - if (nearbyEntity.inventory.any { it != null }) { - // armor stand has equipment, abort! - return@getEntitiesInAABBexcluding false - } - // armor stand has a custom name, is invisible and has no equipment -> probably a "name tag"-armor stand - return@getEntitiesInAABBexcluding true - } - } - false - } - val potentialTimerEntities = arrayListOf() - val potentialNameEntities = arrayListOf() - for (nearby in nearbyArmorStands) { - when { - nearby.displayName.formattedText.startsWith("§8[§7Lv") -> continue - nameStart.any { nearby.displayName.formattedText.startsWith(it) } -> { - printDevMessage( - "expected tier $currentTier, hp $expectedHealth - spawned hp ${entity.baseMaxHealth.toInt()}", - "slayer" - ) - if (expectedHealth == entity.baseMaxHealth.toInt()) { - printDevMessage("hp matched", "slayer") - potentialNameEntities.add(nearby as EntityArmorStand) - } - } - - nearby.displayName.formattedText.matches(timerRegex) -> { - printDevMessage("timer regex matched", "slayer") - potentialTimerEntities.add(nearby as EntityArmorStand) - } - } - } - (this@Slayer as? DemonlordSlayer)?.let { - if (potentialTimerEntities.removeIf { it == quaziiTimer || it == typhoeusTimer }) { - printDevMessage("Ignored demon timers", "slayer") + tickTask(5) { + val nearbyArmorStands = entity.entityWorld.getEntitiesInAABBexcluding( + entity, entity.entityBoundingBox.expand(0.2, 3.0, 0.2) + ) { nearbyEntity: Entity? -> + if (nearbyEntity is EntityArmorStand) { + if (nearbyEntity.isInvisible && nearbyEntity.hasCustomName()) { + if (nearbyEntity.inventory.any { it != null }) { + // armor stand has equipment, abort! + return@getEntitiesInAABBexcluding false } + // armor stand has a custom name, is invisible and has no equipment -> probably a "name tag"-armor stand + return@getEntitiesInAABBexcluding true } - if (potentialNameEntities.size == 1 && potentialTimerEntities.size == 1) { - return@TickTask potentialNameEntities.first() to potentialTimerEntities.first() - } else { + } + false + } + val potentialTimerEntities = arrayListOf() + val potentialNameEntities = arrayListOf() + for (nearby in nearbyArmorStands) { + when { + nearby.displayName.formattedText.startsWith("§8[§7Lv") -> continue + nameStart.any { nearby.displayName.formattedText.startsWith(it) } -> { printDevMessage( - "not the right entity! (${potentialNameEntities.size}, ${potentialTimerEntities.size})", + "expected tier $currentTier, hp $expectedHealth - spawned hp ${entity.baseMaxHealth.toInt()}", "slayer" ) - slayer = null - throw IllegalStateException("Wrong entity!") + if (expectedHealth == entity.baseMaxHealth.toInt()) { + printDevMessage("hp matched", "slayer") + potentialNameEntities.add(nearby as EntityArmorStand) + } } - }.onComplete { - complete(it) + + nearby.displayName.formattedText.matches(timerRegex) -> { + printDevMessage("timer regex matched", "slayer") + potentialTimerEntities.add(nearby as EntityArmorStand) + } + } + } + (this@Slayer as? DemonlordSlayer)?.let { + if (potentialTimerEntities.removeIf { it == quaziiTimer || it == typhoeusTimer }) { + printDevMessage("Ignored demon timers", "slayer") } } + if (potentialNameEntities.size == 1 && potentialTimerEntities.size == 1) { + return@tickTask potentialNameEntities.first() to potentialTimerEntities.first() + } else { + printDevMessage( + "not the right entity! (${potentialNameEntities.size}, ${potentialTimerEntities.size})", + "slayer" + ) + slayer = null + throw IllegalStateException("Wrong entity!") + } } - open fun tick(event: ClientTickEvent) {} open fun set() {} @@ -1036,50 +1028,53 @@ object SlayerFeatures : CoroutineScope { Slayer(entity, "Revenant Horror", "§c☠ §bRevenant Horror", "§c☠ §fAtoned Horror") { override fun set() { - rev5PingTask.register() + rev5PingTask.start() } override fun unset() { - rev5PingTask.unregister() + rev5PingTask.cancel() + rev5PingTask = createrev5PingTask() } companion object { - private val rev5PingTask = TickTask(4, repeats = true, register = false) { - if (Utils.inSkyblock && Skytils.config.rev5TNTPing && mc.thePlayer != null) { - if (hasSlayerText) { - var under: BlockPos? = null - if (mc.thePlayer.onGround) { - under = BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - 0.5, mc.thePlayer.posZ) - } else { - for (i in (mc.thePlayer.posY - 0.5f).toInt() downTo 0 step 1) { - val test = BlockPos(mc.thePlayer.posX, i.toDouble(), mc.thePlayer.posZ) - if (mc.theWorld.getBlockState(test).block !== Blocks.air) { - under = test - break + private fun createrev5PingTask() = + tickTimer(4, repeats = true, register = false) { + if (Utils.inSkyblock && Skytils.config.rev5TNTPing && mc.thePlayer != null) { + if (hasSlayerText) { + var under: BlockPos? = null + if (mc.thePlayer.onGround) { + under = BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - 0.5, mc.thePlayer.posZ) + } else { + for (i in (mc.thePlayer.posY - 0.5f).toInt() downTo 0 step 1) { + val test = BlockPos(mc.thePlayer.posX, i.toDouble(), mc.thePlayer.posZ) + if (mc.theWorld.getBlockState(test).block !== Blocks.air) { + under = test + break + } } } - } - if (under != null) { - val blockUnder = mc.theWorld.getBlockState(under) - val isDanger = when { - blockUnder.block === Blocks.stone_slab && blockUnder.getValue(BlockHalfStoneSlab.VARIANT) == BlockStoneSlab.EnumType.QUARTZ -> true - blockUnder.block === Blocks.quartz_stairs || blockUnder.block === Blocks.acacia_stairs -> true - blockUnder.block === Blocks.wooden_slab && blockUnder.getValue(BlockHalfWoodSlab.VARIANT) == BlockPlanks.EnumType.ACACIA -> true - blockUnder.block === Blocks.stained_hardened_clay -> { - val color = Blocks.stained_hardened_clay.getMetaFromState(blockUnder) - color == 0 || color == 8 || color == 14 - } + if (under != null) { + val blockUnder = mc.theWorld.getBlockState(under) + val isDanger = when { + blockUnder.block === Blocks.stone_slab && blockUnder.getValue(BlockHalfStoneSlab.VARIANT) == BlockStoneSlab.EnumType.QUARTZ -> true + blockUnder.block === Blocks.quartz_stairs || blockUnder.block === Blocks.acacia_stairs -> true + blockUnder.block === Blocks.wooden_slab && blockUnder.getValue(BlockHalfWoodSlab.VARIANT) == BlockPlanks.EnumType.ACACIA -> true + blockUnder.block === Blocks.stained_hardened_clay -> { + val color = Blocks.stained_hardened_clay.getMetaFromState(blockUnder) + color == 0 || color == 8 || color == 14 + } - blockUnder.block === Blocks.bedrock -> true - else -> false - } - if (isDanger) { - SoundQueue.addToQueue("random.orb", 1f) + blockUnder.block === Blocks.bedrock -> true + else -> false + } + if (isDanger) { + SoundQueue.addToQueue("random.orb", 1f) + } } } } } - } + private var rev5PingTask = createrev5PingTask() } } @@ -1138,7 +1133,7 @@ object SlayerFeatures : CoroutineScope { } override fun entityJoinWorld(event: EntityJoinWorldEvent) { - TickTask(1) { + tickTimer(1) { (event.entity as? EntityArmorStand)?.let { e -> if (e.inventory[4]?.item == Item.getItemFromBlock(Blocks.beacon)) { val time = System.currentTimeMillis() - 50 @@ -1165,7 +1160,7 @@ object SlayerFeatures : CoroutineScope { lastYangGlyphSwitch = -1L lastYangGlyphSwitchTicks = -1 } - return@TickTask + return@tickTimer } else if (e.entityBoundingBox.expand(2.0, 3.0, 2.0) .intersectsWith(entity.entityBoundingBox) ) { @@ -1176,7 +1171,7 @@ object SlayerFeatures : CoroutineScope { }) { nukekebiSkulls.add(e) } - return@TickTask + return@tickTimer } } } @@ -1284,35 +1279,39 @@ object SlayerFeatures : CoroutineScope { "SPIRIT" to Color(255, 255, 255) ) - private val blazeFirePingTask = TickTask(4, repeats = true, register = false) { - if (Utils.inSkyblock && Skytils.config.blazeFireWarning && mc.thePlayer != null) { - (slayer as? DemonlordSlayer)?.let { - if (!mc.thePlayer.onGround) return@TickTask - val under = BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - 0.5, mc.thePlayer.posZ) - if (under in it.activeFire) { - // The reason this is a title and not just sound is because there is much less time - // to react to the pit warning than a rev5 tnt ping - createTitle("§c§lFire pit!", 4) - SoundQueue.addToQueue("random.orb", 1f) + private fun createBlazeFirePingTask() = + tickTimer(4, repeats = true, register = false) { + if (Utils.inSkyblock && Skytils.config.blazeFireWarning && mc.thePlayer != null) { + (slayer as? DemonlordSlayer)?.let { + if (!mc.thePlayer.onGround) return@tickTimer + val under = BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - 0.5, mc.thePlayer.posZ) + if (under in it.activeFire) { + // The reason this is a title and not just sound is because there is much less time + // to react to the pit warning than a rev5 tnt ping + createTitle("§c§lFire pit!", 4) + SoundQueue.addToQueue("random.orb", 1f) + } } } } - } + + private var blazeFirePingTask = createBlazeFirePingTask() } override fun set() { - blazeFirePingTask.register() + blazeFirePingTask.start() } override fun unset() { - blazeFirePingTask.unregister() + blazeFirePingTask.cancel() + blazeFirePingTask = createBlazeFirePingTask() } override fun tick(event: ClientTickEvent) { if (entity.isInvisible && !lastTickInvis) { lastTickInvis = true val prevBB = entity.entityBoundingBox.expand(3.0, 1.5, 3.0) - TickTask(10) { + tickTimer(10) { val demons = entity.entityWorld.getEntitiesInAABBexcluding( entity, prevBB ) { it is EntityPigZombie || (it is EntitySkeleton && it.skeletonType == 1) } @@ -1350,7 +1349,7 @@ object SlayerFeatures : CoroutineScope { override fun entityJoinWorld(event: EntityJoinWorldEvent) { (event.entity as? EntityArmorStand)?.let { e -> - TickTask(1) { + tickTimer(1) { if (e.inventory[4]?.takeIf { it.item is ItemSkull } ?.let { ItemUtil.getSkullTexture(it) == thrownTexture } == true) { printDevMessage( @@ -1358,7 +1357,7 @@ object SlayerFeatures : CoroutineScope { "slayer", ) thrownEntity = e - return@TickTask + return@tickTimer } else if (e.name.matches(totemRegex) && e.getDistanceSq(totemPos) < 9) { totemEntity = e } diff --git a/src/main/kotlin/gg/skytils/skytilsmod/gui/WaypointsGui.kt b/src/main/kotlin/gg/skytils/skytilsmod/gui/WaypointsGui.kt index af9179ab8..79892d36e 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/gui/WaypointsGui.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/gui/WaypointsGui.kt @@ -33,7 +33,7 @@ import gg.essential.vigilance.utils.onLeftClick import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.Skytils.Companion.mc import gg.skytils.skytilsmod.core.PersistentSave -import gg.skytils.skytilsmod.core.TickTask +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.features.impl.handlers.Waypoint import gg.skytils.skytilsmod.features.impl.handlers.WaypointCategory import gg.skytils.skytilsmod.features.impl.handlers.Waypoints @@ -257,7 +257,7 @@ class WaypointsGui : WindowScreen(ElementaVersion.V2, newGuiScale = 2), Reopenab y = 5.pixels(alignOpposite = true) }.onLeftClick { mc.displayGuiScreen(null) - TickTask(2) { + tickTimer(2) { Skytils.displayScreen = WaypointShareGui() } } diff --git a/src/main/kotlin/gg/skytils/skytilsmod/listeners/DungeonListener.kt b/src/main/kotlin/gg/skytils/skytilsmod/listeners/DungeonListener.kt index 3eae48369..d63cb8807 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/listeners/DungeonListener.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/listeners/DungeonListener.kt @@ -26,7 +26,7 @@ import gg.skytils.skytilsmod.Skytils import gg.skytils.skytilsmod.Skytils.Companion.failPrefix import gg.skytils.skytilsmod.Skytils.Companion.mc import gg.skytils.skytilsmod.commands.impl.RepartyCommand -import gg.skytils.skytilsmod.core.TickTask +import gg.skytils.skytilsmod.core.tickTimer import gg.skytils.skytilsmod.events.impl.MainReceivePacketEvent import gg.skytils.skytilsmod.events.impl.skyblock.DungeonEvent import gg.skytils.skytilsmod.features.impl.dungeons.DungeonTimer @@ -93,14 +93,14 @@ object DungeonListener { team.clear() deads.clear() missingPuzzles.clear() - TickTask(40) { + tickTimer(40) { getMembers() } } else if (text.stripControlCodes() .trim() == "> EXTRA STATS <" ) { if (Skytils.config.dungeonDeathCounter) { - TickTask(6) { + tickTimer(6) { UChat.chat("§c☠ §lDeaths:§r ${team.values.sumOf { it.deaths }}\n${ team.values.filter { it.deaths > 0 }.sortedByDescending { it.deaths }.joinToString("\n") { " §c☠ ${it.playerName}:§r ${it.deaths}" @@ -127,8 +127,8 @@ object DungeonListener { } init { - TickTask(4, repeats = true) { - if (!Utils.inDungeons) return@TickTask + tickTimer(4, repeats = true) { + if (!Utils.inDungeons) return@tickTimer val localMissingPuzzles = TabListUtils.tabEntries.mapNotNull { val name = it.second if (name.contains("✦")) { @@ -155,7 +155,7 @@ object DungeonListener { missingPuzzles.addAll(localMissingPuzzles) } } - TickTask(2, repeats = true) { + tickTimer(2, repeats = true) { if (Utils.inDungeons && (DungeonTimer.scoreShownAt == -1L || System.currentTimeMillis() - DungeonTimer.scoreShownAt < 1500)) { val tabEntries = TabListUtils.tabEntries val self = team[mc.thePlayer.name] @@ -195,7 +195,7 @@ object DungeonListener { printDevMessage(isFirstDeath.toString(), "spiritpet") printDevMessage(ScoreCalculation.firstDeathHadSpirit.toString(), "spiritpet") if (Skytils.config.dungeonDeathCounter) { - TickTask(1) { + tickTimer(1) { UChat.chat( "§bThis is §e${teammate.playerName}§b's §e${teammate.deaths.addSuffix()}§b death out of §e${totalDeaths}§b total tracked deaths.${ " §6(SPIRIT)".toStringIfTrue( @@ -228,7 +228,7 @@ object DungeonListener { val tabEntries = TabListUtils.tabEntries if (tabEntries.isEmpty() || !tabEntries[0].second.contains("§r§b§lParty §r§f(")) { - TickTask(5) { + tickTimer(5) { getMembers() } return @@ -237,7 +237,7 @@ object DungeonListener { val partyCount = partyCountPattern.find(tabEntries[0].second)?.groupValues?.get(1)?.toIntOrNull() if (partyCount == null) { println("Couldn't get party count") - TickTask(5) { + tickTimer(5) { getMembers() } return