diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-28 01:19:40 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-28 01:19:40 +0100 |
commit | babfa567f8149a89f410e82d6f539fc7fa5a714c (patch) | |
tree | c0165ccdeac697ba8a678fd299c941df9480a69f /src/main/java/at/hannibal2/skyhanni/data | |
parent | 122fdc9831c87038511c23e96d868482e588387d (diff) | |
download | skyhanni-babfa567f8149a89f410e82d6f539fc7fa5a714c.tar.gz skyhanni-babfa567f8149a89f410e82d6f539fc7fa5a714c.tar.bz2 skyhanni-babfa567f8149a89f410e82d6f539fc7fa5a714c.zip |
Fixed Item Tracker not ignoring manual sack movements
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt | 23 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt | 6 |
2 files changed, 24 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt index a05d8398f..3d4b8f067 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt @@ -1,5 +1,7 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.InventoryOpenEvent import at.hannibal2.skyhanni.events.ItemAddEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.SackChangeEvent @@ -11,6 +13,7 @@ import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.StringUtils.matches import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds +import kotlin.time.Duration.Companion.seconds class ItemAddManager { enum class Source { @@ -25,10 +28,30 @@ class ItemAddManager { private val diceRollChatPattern = "§eYour §r§(5|6High Class )Archfiend Dice §r§erolled a §r§.(?<number>.)§r§e! Bonus: §r§.(?<hearts>.*)❤".toPattern() + private var inSackInventory = false + private var lastSackInventoryLeave = SimpleTimeMark.farPast() + + @SubscribeEvent + fun onInventoryOpen(event: InventoryOpenEvent) { + if (event.inventoryName.contains("Sack")) { + inSackInventory = true + } + } + + @SubscribeEvent + fun onInventoryClose(event: GuiContainerEvent.CloseWindowEvent) { + if (inSackInventory) { + inSackInventory = false + lastSackInventoryLeave = SimpleTimeMark.now() + } + } + @SubscribeEvent fun onSackChange(event: SackChangeEvent) { if (!LorenzUtils.inSkyBlock) return + if (inSackInventory || lastSackInventoryLeave.passedSince() < 10.seconds) return + for (sackChange in event.sackChanges) { val change = sackChange.delta if (change > 0) { diff --git a/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt index 6e128b776..605aca858 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt @@ -6,8 +6,6 @@ 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.features.bazaar.BazaarApi -import at.hannibal2.skyhanni.features.bazaar.BazaarApi.Companion.isBazaarItem import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull import at.hannibal2.skyhanni.utils.LorenzUtils @@ -92,9 +90,7 @@ class OwnInventoryData { @SubscribeEvent fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { - if (BazaarApi.inBazaarInventory) { - ignoreItem(500.milliseconds) { it.isBazaarItem() } - } + ignoreItem(500.milliseconds) { true } } private fun ignoreItem(duration: Duration, condition: (NEUInternalName) -> Boolean) { |