From 82370ca380c81aa06aa10aef483147778be15253 Mon Sep 17 00:00:00 2001 From: Mikecraft1224 <85994411+Mikecraft1224@users.noreply.github.com> Date: Mon, 6 May 2024 17:30:05 +0200 Subject: Fixed highlights in inventory staying when exiting via NEU recipes (#1699) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 ++ .../java/at/hannibal2/skyhanni/data/ScreenData.kt | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/data/ScreenData.kt (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index b17773c4b..219745a33 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -48,6 +48,7 @@ import at.hannibal2.skyhanni.data.QuiverAPI import at.hannibal2.skyhanni.data.RenderData import at.hannibal2.skyhanni.data.SackAPI import at.hannibal2.skyhanni.data.ScoreboardData +import at.hannibal2.skyhanni.data.ScreenData import at.hannibal2.skyhanni.data.SkillExperience import at.hannibal2.skyhanni.data.SlayerAPI import at.hannibal2.skyhanni.data.TitleData @@ -518,6 +519,7 @@ class SkyHanniMod { loadModule(VisitorListener()) loadModule(VisitorRewardWarning()) loadModule(OwnInventoryData()) + loadModule(ScreenData) loadModule(HighlightVisitorsOutsideOfGarden()) loadModule(GuiEditManager()) loadModule(GetFromSackAPI) diff --git a/src/main/java/at/hannibal2/skyhanni/data/ScreenData.kt b/src/main/java/at/hannibal2/skyhanni/data/ScreenData.kt new file mode 100644 index 000000000..194983695 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/ScreenData.kt @@ -0,0 +1,20 @@ +package at.hannibal2.skyhanni.data + +import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import net.minecraft.client.Minecraft +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object ScreenData { + private var wasOpen = false + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + val isOpen = Minecraft.getMinecraft().currentScreen != null + if (wasOpen == isOpen) return + wasOpen = isOpen + if (!wasOpen) { + InventoryCloseEvent(false).postAndCatch() + } + } +} -- cgit