summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/mixins/hooks
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2024-05-03 12:15:45 +0200
committerGitHub <noreply@github.com>2024-05-03 12:15:45 +0200
commit4a2ac4ca162d846dcc9a2a3227f963321fa4e22a (patch)
tree3bd7a448f61e58e02f1e81778a40aa3b964fd8b7 /src/main/java/at/hannibal2/skyhanni/mixins/hooks
parent8d338540f3293b03acdd74f40a6c84a3cbedbded (diff)
downloadskyhanni-4a2ac4ca162d846dcc9a2a3227f963321fa4e22a.tar.gz
skyhanni-4a2ac4ca162d846dcc9a2a3227f963321fa4e22a.tar.bz2
skyhanni-4a2ac4ca162d846dcc9a2a3227f963321fa4e22a.zip
Backend: GuiContainerEvent.BeforeDraw (#1510)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/mixins/hooks')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt
index 3304534a3..72f4a2e90 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt
@@ -1,10 +1,12 @@
package at.hannibal2.skyhanni.mixins.hooks
+import at.hannibal2.skyhanni.data.GuiData
import at.hannibal2.skyhanni.events.DrawScreenAfterEvent
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.GuiContainerEvent.CloseWindowEvent
import at.hannibal2.skyhanni.events.GuiContainerEvent.SlotClickEvent
import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests
+import io.github.moulberry.notenoughupdates.NEUApi
import net.minecraft.client.gui.inventory.GuiContainer
import net.minecraft.inventory.Slot
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo
@@ -26,6 +28,22 @@ class GuiContainerHook(guiAny: Any) {
GuiContainerEvent.BackgroundDrawnEvent(gui, gui.inventorySlots, mouseX, mouseY, partialTicks).postAndCatch()
}
+ fun preDraw(
+ mouseX: Int,
+ mouseY: Int,
+ partialTicks: Float,
+ ci: CallbackInfo,
+ ) {
+ if (!SkyHanniDebugsAndTests.globalRender) return
+ if (GuiContainerEvent.BeforeDraw(gui, gui.inventorySlots, mouseX, mouseY, partialTicks).postAndCatch()) {
+ NEUApi.setInventoryButtonsToDisabled()
+ GuiData.preDrawEventCanceled = true
+ ci.cancel()
+ } else {
+ GuiData.preDrawEventCanceled = false
+ }
+ }
+
fun foregroundDrawn(mouseX: Int, mouseY: Int, partialTicks: Float) {
GuiContainerEvent.ForegroundDrawnEvent(gui, gui.inventorySlots, mouseX, mouseY, partialTicks).postAndCatch()
}
@@ -52,4 +70,5 @@ class GuiContainerHook(guiAny: Any) {
) {
if (DrawScreenAfterEvent(mouseX, mouseY, ci).postAndCatch()) ci.cancel()
}
+
}