From e3e3ea54f954feb4d55a93a04b851de32d118ecb Mon Sep 17 00:00:00 2001 From: MachineMuse Date: Wed, 4 Sep 2013 15:00:04 -0600 Subject: [PATCH] Added mouse event --- .../client/ForgeHooksClient.java | 5 +++ .../client/event/MouseEvent.java | 32 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 client/net/minecraftforge/client/event/MouseEvent.java diff --git a/client/net/minecraftforge/client/ForgeHooksClient.java b/client/net/minecraftforge/client/ForgeHooksClient.java index a49b48e8c..a2c2b0103 100644 --- a/client/net/minecraftforge/client/ForgeHooksClient.java +++ b/client/net/minecraftforge/client/ForgeHooksClient.java @@ -6,6 +6,7 @@ import java.util.TreeSet; import javax.imageio.ImageIO; +import net.minecraftforge.client.event.MouseEvent; import org.lwjgl.LWJGLException; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.GL11; @@ -325,6 +326,10 @@ public class ForgeHooksClient } } + public static boolean postMouseEvent() { + return MinecraftForge.EVENT_BUS.post(new MouseEvent()); + } + /** * Initialization of Forge Renderers. */ diff --git a/client/net/minecraftforge/client/event/MouseEvent.java b/client/net/minecraftforge/client/event/MouseEvent.java new file mode 100644 index 000000000..1c3a1df9f --- /dev/null +++ b/client/net/minecraftforge/client/event/MouseEvent.java @@ -0,0 +1,32 @@ +package net.minecraftforge.client.event; + +import net.minecraftforge.event.Cancelable; +import net.minecraftforge.event.Event; +import org.lwjgl.input.Mouse; + +/** + * Author: MachineMuse (Claire Semple) + * Created: 2:46 PM, 9/4/13 + */ +@Cancelable +public class MouseEvent extends Event { + public final int x; + public final int y; + public final int dx; + public final int dy; + public final int dwheel; + public final int button; + public final boolean buttonstate; + public final long nanoseconds; + + public MouseEvent() { + this.x = Mouse.getEventX(); + this.y = Mouse.getEventY(); + this.dx = Mouse.getEventDX(); + this.dy = Mouse.getEventDY(); + this.dwheel = Mouse.getEventDWheel(); + this.button = Mouse.getEventButton(); + this.buttonstate = Mouse.getEventButtonState(); + this.nanoseconds = Mouse.getEventNanoseconds(); + } +}