diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/ScreenData.kt | 20 |
2 files changed, 22 insertions, 0 deletions
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() + } + } +} |