Skip to content

Commit

Permalink
chore: migrate ticktasks to new tick api
Browse files Browse the repository at this point in the history
  • Loading branch information
Sychic committed Nov 10, 2023
1 parent aa29d0d commit adec375
Show file tree
Hide file tree
Showing 30 changed files with 196 additions and 197 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/gg/skytils/skytilsmod/Skytils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<String>().apply {
if (Skytils.config.dungeonTimer) {
add("§7Wither Doors: $witherDoors")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -51,15 +51,15 @@ 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"
)
) {
calcOrder()
}
}
TickTask(20, repeats = true) {
tickTimer(20, repeats = true) {
if (Skytils.config.blazeSolver && Utils.inDungeons && DungeonListener.missingPuzzles.contains(
"Higher Or Lower"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -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"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -61,12 +61,12 @@ object AlignmentTaskSolver {
private val directionSet = HashMap<Point, Int>()

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 != "" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -61,10 +61,10 @@ object MayorInfo {
private val jerryNextPerkRegex = Regex("§7Next set of perks in §e(?<h>\\d+?)h (?<m>\\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)
Expand Down Expand Up @@ -134,7 +134,7 @@ object MayorInfo {

fun fetchMayorData() = Skytils.IO.launch {
val res = json.decodeFromJsonElement<Mayor>(client.get("https://api.hypixel.net/resources/skyblock/election").body<JsonObject>()["mayor"]!!)
TickTask(1) {
tickTimer(1) {
currentMayor = res.name
lastFetchedMayorData = System.currentTimeMillis()
if (currentMayor != "Jerry") jerryMayor = null
Expand All @@ -145,7 +145,7 @@ object MayorInfo {

fun fetchJerryData() = Skytils.IO.launch {
val res = client.get("https://${Skytils.domain}/api/mayor").body<JerrySession>()
TickTask(1) {
tickTimer(1) {
newJerryPerks = res.nextSwitch
jerryMayor = res.mayor
}
Expand Down
Loading

0 comments on commit adec375

Please sign in to comment.