diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-14 16:47:30 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-14 16:47:30 +0100 |
commit | 375ce339ffd66e5aeadace6183b84309d484c954 (patch) | |
tree | cc037fb333f95fce8455e2ff9bd6a6dc299aca35 /src | |
parent | a32e4f54eb6da926365199d4165d61354cccce83 (diff) | |
download | skyhanni-375ce339ffd66e5aeadace6183b84309d484c954.tar.gz skyhanni-375ce339ffd66e5aeadace6183b84309d484c954.tar.bz2 skyhanni-375ce339ffd66e5aeadace6183b84309d484c954.zip |
Fixed issue with garden features not detecting tool in the hand when swapping item in inventory and closing inventory immediately after that
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt | 25 |
1 files changed, 15 insertions, 10 deletions
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 d3cf87954..44c80f381 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.GardenCropMilestones import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.GardenToolChangeEvent +import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -20,15 +21,15 @@ class GardenAPI { @SubscribeEvent fun onSendPacket(event: PacketEvent.SendEvent) { - val packet = event.packet - if (packet !is C09PacketHeldItemChange) return + if (!inGarden()) return + if (event.packet !is C09PacketHeldItemChange) return + checkItemInHand() + } - val heldItem = Minecraft.getMinecraft().thePlayer.heldItem - val crop = loadCropInHand(heldItem) - if (cropInHand != crop) { - cropInHand = crop - GardenToolChangeEvent(crop, heldItem).postAndCatch() - } + @SubscribeEvent + fun onCloseWindow(event: GuiContainerEvent.CloseWindowEvent) { + if (!inGarden()) return + checkItemInHand() } @SubscribeEvent @@ -37,11 +38,15 @@ class GardenAPI { if (!inGarden()) return if (tick++ % 10 != 0) return + // We ignore random hypixel moments + Minecraft.getMinecraft().currentScreen ?: return + checkItemInHand() + } + + private fun checkItemInHand() { val heldItem = Minecraft.getMinecraft().thePlayer.heldItem val crop = loadCropInHand(heldItem) if (cropInHand != crop) { - // We ignore random hypixel moments - Minecraft.getMinecraft().currentScreen ?: return cropInHand = crop GardenToolChangeEvent(crop, heldItem).postAndCatch() } |