aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt16
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/WildStrawberryDyeNotification.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt28
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt4
6 files changed, 28 insertions, 34 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt
index ada0e4029..eb32c929c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt
@@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.OwnInventoryItemUpdateEvent
import at.hannibal2.skyhanni.events.SackChangeEvent
import at.hannibal2.skyhanni.utils.ConfigUtils
+import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
@@ -24,7 +25,6 @@ import at.hannibal2.skyhanni.utils.NumberUtil.format
import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker
import at.hannibal2.skyhanni.utils.tracker.TrackerData
import com.google.gson.annotations.Expose
-import io.github.moulberry.notenoughupdates.util.MinecraftExecutor
import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -130,7 +130,7 @@ object EnderNodeTracker {
if (!isInTheEnd()) return
if (!ProfileStorageData.loaded) return
- MinecraftExecutor.OnThread.execute {
+ DelayedRun.runNow {
val newMiteGelInInventory = Minecraft.getMinecraft().thePlayer.inventory.mainInventory
.filter { it?.getInternalNameOrNull() == EnderNode.MITE_GEL.internalName }
.sumOf { it.stackSize }
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 0ac45f8c1..aafd3fd7c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
@@ -23,19 +23,16 @@ import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI
import at.hannibal2.skyhanni.features.garden.inventory.SkyMartCopperPrice
import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI
import at.hannibal2.skyhanni.utils.BlockUtils.isBabyCrop
+import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LocationUtils.isPlayerInside
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.LorenzVec
-import at.hannibal2.skyhanni.utils.MinecraftDispatcher
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getCultivatingCounter
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getHoeCounter
-import kotlinx.coroutines.delay
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.withContext
import net.minecraft.client.Minecraft
import net.minecraft.item.ItemStack
import net.minecraft.network.play.client.C09PacketHeldItemChange
@@ -99,14 +96,12 @@ object GardenAPI {
}
}
+ // TODO use IslandChangeEvent
@SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
- SkyHanniMod.coroutineScope.launch {
- delay(2.seconds)
- withContext(MinecraftDispatcher) {
- if (inGarden()) {
- checkItemInHand()
- }
+ DelayedRun.runDelayed(2.seconds) {
+ if (inGarden()) {
+ checkItemInHand()
}
}
}
@@ -185,7 +180,6 @@ object GardenAPI {
val cropBroken = blockState.getCropType() ?: return
if (cropBroken.multiplier == 1 && blockState.isBabyCrop()) return
-
val position = event.position
if (lastLocation == position) {
return
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/WildStrawberryDyeNotification.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/WildStrawberryDyeNotification.kt
index dc5f17064..c35cf5495 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/WildStrawberryDyeNotification.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/WildStrawberryDyeNotification.kt
@@ -3,13 +3,13 @@ package at.hannibal2.skyhanni.features.garden.farming
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.OwnInventoryItemUpdateEvent
import at.hannibal2.skyhanni.features.garden.GardenAPI
+import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.ItemBlink
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.SoundUtils
-import io.github.moulberry.notenoughupdates.util.MinecraftExecutor
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.seconds
@@ -29,11 +29,11 @@ class WildStrawberryDyeNotification {
if (!GardenAPI.config.wildStrawberryDyeNotification) return
val itemStack = event.itemStack
- MinecraftExecutor.OnThread.execute {
+ DelayedRun.runNow {
// Prevent false positives when buying the item in ah or moving it from a storage
val diff = System.currentTimeMillis() - lastCloseTime
- if (diff < 1_000) return@execute
+ if (diff < 1_000) return@runNow
val internalName = itemStack.getInternalName()
if (internalName == item) {
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 fcde7ca24..f8b5214b5 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
@@ -22,6 +22,7 @@ import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.ConfigUtils
+import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemBlink
@@ -48,7 +49,6 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TimeUtils
import at.hannibal2.skyhanni.utils.getLorenzVec
import at.hannibal2.skyhanni.utils.renderables.Renderable
-import io.github.moulberry.notenoughupdates.util.MinecraftExecutor
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiEditSign
import net.minecraft.entity.EntityLivingBase
@@ -234,7 +234,7 @@ class GardenVisitorFeatures {
@SubscribeEvent
fun onOwnInventoryItemUpdate(event: OwnInventoryItemUpdateEvent) {
if (GardenAPI.onBarnPlot) {
- MinecraftExecutor.OnThread.execute {
+ DelayedRun.runNow {
update()
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt
index 59ca5b075..04275f1a9 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt
@@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.events.withAlpha
import at.hannibal2.skyhanni.features.rift.RiftAPI
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
+import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.EntityUtils.canBeSeen
import at.hannibal2.skyhanni.utils.EntityUtils.getAllNameTagsInRadiusWith
@@ -23,7 +24,6 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy
import at.hannibal2.skyhanni.utils.LorenzUtils.toChromaColor
-import at.hannibal2.skyhanni.utils.MinecraftDispatcher
import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine
import at.hannibal2.skyhanni.utils.RenderUtils.drawColor
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
@@ -36,7 +36,6 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
-import kotlinx.coroutines.withContext
import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraft.client.renderer.GlStateManager
@@ -136,21 +135,18 @@ object VampireSlayerFeatures {
else taggedEntityList.contains(this.entityId) && configOtherBoss.twinClawsSound
if (shouldSendTitle || shouldSendSound) {
- SkyHanniMod.coroutineScope.launch {
- delay(config.twinclawsDelay.milliseconds)
- withContext(MinecraftDispatcher) {
- if (nextClawSend < System.currentTimeMillis()) {
- if (shouldSendSound)
- playTwinclawsSound()
- if (shouldSendTitle) {
- LorenzUtils.sendTitle(
- "§6§lTWINCLAWS",
- (1750 - config.twinclawsDelay).milliseconds,
- 2.6
- )
- }
- nextClawSend = System.currentTimeMillis() + 5_000
+ DelayedRun.runDelayed(config.twinclawsDelay.milliseconds) {
+ if (nextClawSend < System.currentTimeMillis()) {
+ if (shouldSendSound)
+ playTwinclawsSound()
+ if (shouldSendTitle) {
+ LorenzUtils.sendTitle(
+ "§6§lTWINCLAWS",
+ (1750 - config.twinclawsDelay).milliseconds,
+ 2.6
+ )
}
+ nextClawSend = System.currentTimeMillis() + 5_000
}
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt b/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt
index 0fa9152cd..cbc413c22 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt
@@ -9,6 +9,10 @@ object DelayedRun {
map[run] = SimpleTimeMark.now() + duration
}
+ fun runNow(run: () -> Unit) {
+ map[run] = SimpleTimeMark.now()
+ }
+
fun checkRuns() {
map.entries.removeIf { (runnable, time) ->
val inPast = time.isInPast()