aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/OwnInventoryItemUpdateEvent.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt19
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/WildStrawberryDyeNotification.kt25
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt2
6 files changed, 26 insertions, 35 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt
index 605aca858..a7b31159b 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt
@@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.OwnInventoryItemUpdateEvent
import at.hannibal2.skyhanni.events.PacketEvent
import at.hannibal2.skyhanni.events.entity.ItemAddInInventoryEvent
+import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull
import at.hannibal2.skyhanni.utils.LorenzUtils
@@ -36,7 +37,9 @@ class OwnInventoryData {
val windowId = packet.func_149175_c()
if (windowId == 0) {
val item = packet.func_149174_e() ?: return
- OwnInventoryItemUpdateEvent(item).postAndCatch()
+ DelayedRun.runNextTick {
+ OwnInventoryItemUpdateEvent(item).postAndCatch()
+ }
}
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/events/OwnInventoryItemUpdateEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/OwnInventoryItemUpdateEvent.kt
index a7a5ba491..32e19e751 100644
--- a/src/main/java/at/hannibal2/skyhanni/events/OwnInventoryItemUpdateEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/events/OwnInventoryItemUpdateEvent.kt
@@ -2,7 +2,4 @@ package at.hannibal2.skyhanni.events
import net.minecraft.item.ItemStack
-/**
- * Note: This event is async and may not be executed on the main minecraft thread.
- */
-data class OwnInventoryItemUpdateEvent(val itemStack: ItemStack) : LorenzEvent() \ No newline at end of file
+data class OwnInventoryItemUpdateEvent(val itemStack: ItemStack) : LorenzEvent()
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 eb32c929c..51f9a7e8b 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,7 +12,6 @@ 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
@@ -130,18 +129,16 @@ object EnderNodeTracker {
if (!isInTheEnd()) return
if (!ProfileStorageData.loaded) return
- DelayedRun.runNow {
- val newMiteGelInInventory = Minecraft.getMinecraft().thePlayer.inventory.mainInventory
- .filter { it?.getInternalNameOrNull() == EnderNode.MITE_GEL.internalName }
- .sumOf { it.stackSize }
- val change = newMiteGelInInventory - miteGelInInventory
- if (change > 0) {
- tracker.modify { storage ->
- storage.lootCount.addOrPut(EnderNode.MITE_GEL, change)
- }
+ val newMiteGelInInventory = Minecraft.getMinecraft().thePlayer.inventory.mainInventory
+ .filter { it?.getInternalNameOrNull() == EnderNode.MITE_GEL.internalName }
+ .sumOf { it.stackSize }
+ val change = newMiteGelInInventory - miteGelInInventory
+ if (change > 0) {
+ tracker.modify { storage ->
+ storage.lootCount.addOrPut(EnderNode.MITE_GEL, change)
}
- miteGelInInventory = newMiteGelInInventory
}
+ miteGelInInventory = newMiteGelInInventory
}
@SubscribeEvent
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 c35cf5495..aaa1a734c 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,7 +3,6 @@ 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
@@ -30,19 +29,17 @@ class WildStrawberryDyeNotification {
val itemStack = event.itemStack
- 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@runNow
-
- val internalName = itemStack.getInternalName()
- if (internalName == item) {
- val name = itemStack.name!!
- LorenzUtils.sendTitle(name, 5.seconds)
- LorenzUtils.chat("You found a $name§e!")
- SoundUtils.playBeepSound()
- ItemBlink.setBlink(itemStack, 5_000)
- }
+ // 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
+
+ val internalName = itemStack.getInternalName()
+ if (internalName == item) {
+ val name = itemStack.name!!
+ LorenzUtils.sendTitle(name, 5.seconds)
+ LorenzUtils.chat("You found a $name§e!")
+ SoundUtils.playBeepSound()
+ ItemBlink.setBlink(itemStack, 5_000)
}
}
}
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 f8b5214b5..ed0627d82 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,7 +22,6 @@ 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
@@ -234,9 +233,7 @@ class GardenVisitorFeatures {
@SubscribeEvent
fun onOwnInventoryItemUpdate(event: OwnInventoryItemUpdateEvent) {
if (GardenAPI.onBarnPlot) {
- DelayedRun.runNow {
- update()
- }
+ update()
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt b/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt
index cbc413c22..2af59435d 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt
@@ -9,7 +9,7 @@ object DelayedRun {
map[run] = SimpleTimeMark.now() + duration
}
- fun runNow(run: () -> Unit) {
+ fun runNextTick(run: () -> Unit) {
map[run] = SimpleTimeMark.now()
}