diff --git a/patches/minecraft/net/minecraft/client/gui/GuiScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiScreen.java.patch index 28ebe9f9d..b155c038c 100644 --- a/patches/minecraft/net/minecraft/client/gui/GuiScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/GuiScreen.java.patch @@ -91,3 +91,23 @@ } public void func_73866_w_() {} +@@ -246,7 +265,9 @@ + { + while (Mouse.next()) + { ++ if (MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.MouseInputEvent.Pre(this))) continue; + this.func_146274_d(); ++ if (this.equals(this.field_146297_k.field_71462_r)) MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.MouseInputEvent.Post(this)); + } + } + +@@ -254,7 +275,9 @@ + { + while (Keyboard.next()) + { ++ if (MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.KeyboardInputEvent.Pre(this))) continue; + this.func_146282_l(); ++ if (this.equals(this.field_146297_k.field_71462_r)) MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.KeyboardInputEvent.Post(this)); + } + } + } diff --git a/patches/minecraft/net/minecraft/client/gui/inventory/GuiContainer.java.patch b/patches/minecraft/net/minecraft/client/gui/inventory/GuiContainer.java.patch index b795376e9..71eb1171e 100644 --- a/patches/minecraft/net/minecraft/client/gui/inventory/GuiContainer.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/inventory/GuiContainer.java.patch @@ -46,3 +46,20 @@ Slot slot = this.func_146975_c(p_146286_1_, p_146286_2_); int l = this.field_147003_i; int i1 = this.field_147009_r; +@@ -691,4 +702,16 @@ + this.field_146297_k.field_71439_g.func_71053_j(); + } + } ++ ++ /* ======================================== FORGE START =====================================*/ ++ ++ /** ++ * Returns the slot that is currently displayed under the mouse. ++ */ ++ public Slot getSlotUnderMouse() ++ { ++ return this.field_147006_u; ++ } ++ ++ /* ======================================== FORGE END =====================================*/ + } diff --git a/src/main/java/net/minecraftforge/client/event/GuiScreenEvent.java b/src/main/java/net/minecraftforge/client/event/GuiScreenEvent.java index 07e0bd051..db4efe00f 100644 --- a/src/main/java/net/minecraftforge/client/event/GuiScreenEvent.java +++ b/src/main/java/net/minecraftforge/client/event/GuiScreenEvent.java @@ -176,4 +176,70 @@ public class GuiScreenEvent extends Event } } } + + public static class MouseInputEvent extends GuiScreenEvent + { + public MouseInputEvent(GuiScreen gui) + { + super(gui); + } + + /** + * This event fires when mouse input is detected by a GuiScreen. + * Cancel this event to bypass {@code GuiScreen.handleMouseInput()}. + */ + @Cancelable + public static class Pre extends MouseInputEvent + { + public Pre(GuiScreen gui) + { + super(gui); + } + } + + /** + * This event fires after {@code GuiScreen.handleMouseInput()} provided that the active + * screen has not been changed as a result of {@code GuiScreen.handleMouseInput()}. + */ + public static class Post extends MouseInputEvent + { + public Post(GuiScreen gui) + { + super(gui); + } + } + } + + public static class KeyboardInputEvent extends GuiScreenEvent + { + public KeyboardInputEvent(GuiScreen gui) + { + super(gui); + } + + /** + * This event fires when keyboard input is detected by a GuiScreen. + * Cancel this event to bypass {@code GuiScreen.handleKeyboardInput()}. + */ + @Cancelable + public static class Pre extends KeyboardInputEvent + { + public Pre(GuiScreen gui) + { + super(gui); + } + } + + /** + * This event fires after {@code GuiScreen.handleKeyboardInput()} provided that the active + * screen has not been changed as a result of {@code GuiScreen.handleKeyboardInput()}. + */ + public static class Post extends KeyboardInputEvent + { + public Post(GuiScreen gui) + { + super(gui); + } + } + } }