Reimplemented "MouseEvent" as RawMouseEvent for 1.14.X (#6144)

This commit is contained in:
MrCrayfish 2019-09-17 05:33:10 +09:30 committed by LexManos
parent 60eecb98a6
commit f4215d121c
3 changed files with 72 additions and 7 deletions

View file

@ -1,6 +1,13 @@
--- a/net/minecraft/client/MouseHelper.java --- a/net/minecraft/client/MouseHelper.java
+++ b/net/minecraft/client/MouseHelper.java +++ b/net/minecraft/client/MouseHelper.java
@@ -77,11 +77,15 @@ @@ -71,17 +71,22 @@
if (!this.field_198051_p && flag) {
this.func_198034_i();
}
+ if (net.minecraftforge.client.ForgeHooksClient.onRawMouseClicked(p_198023_3_, p_198023_4_, p_198023_5_)) return;
} else {
double d0 = this.field_198040_e * (double)this.field_198036_a.field_195558_d.func_198107_o() / (double)this.field_198036_a.field_195558_d.func_198105_m();
double d1 = this.field_198041_f * (double)this.field_198036_a.field_195558_d.func_198087_p() / (double)this.field_198036_a.field_195558_d.func_198083_n();
int p_198023_3_f = p_198023_3_; int p_198023_3_f = p_198023_3_;
if (flag) { if (flag) {
Screen.wrapScreenError(() -> { Screen.wrapScreenError(() -> {
@ -18,7 +25,7 @@
}, "mouseReleased event handler", this.field_198036_a.field_71462_r.getClass().getCanonicalName()); }, "mouseReleased event handler", this.field_198036_a.field_71462_r.getClass().getCanonicalName());
} }
} }
@@ -105,7 +109,7 @@ @@ -105,7 +110,7 @@
} }
} }
} }
@ -27,7 +34,7 @@
} }
} }
@@ -116,7 +120,9 @@ @@ -116,7 +121,9 @@
if (this.field_198036_a.field_71462_r != null) { if (this.field_198036_a.field_71462_r != null) {
double d1 = this.field_198040_e * (double)this.field_198036_a.field_195558_d.func_198107_o() / (double)this.field_198036_a.field_195558_d.func_198105_m(); double d1 = this.field_198040_e * (double)this.field_198036_a.field_195558_d.func_198107_o() / (double)this.field_198036_a.field_195558_d.func_198105_m();
double d2 = this.field_198041_f * (double)this.field_198036_a.field_195558_d.func_198087_p() / (double)this.field_198036_a.field_195558_d.func_198083_n(); double d2 = this.field_198041_f * (double)this.field_198036_a.field_195558_d.func_198087_p() / (double)this.field_198036_a.field_195558_d.func_198083_n();
@ -38,7 +45,7 @@
} else if (this.field_198036_a.field_71439_g != null) { } else if (this.field_198036_a.field_71439_g != null) {
if (this.field_200542_o != 0.0D && Math.signum(d0) != Math.signum(this.field_200542_o)) { if (this.field_200542_o != 0.0D && Math.signum(d0) != Math.signum(this.field_200542_o)) {
this.field_200542_o = 0.0D; this.field_200542_o = 0.0D;
@@ -129,6 +135,7 @@ @@ -129,6 +136,7 @@
} }
this.field_200542_o -= (double)f1; this.field_200542_o -= (double)f1;
@ -46,7 +53,7 @@
if (this.field_198036_a.field_71439_g.func_175149_v()) { if (this.field_198036_a.field_71439_g.func_175149_v()) {
if (this.field_198036_a.field_71456_v.func_175187_g().func_175262_a()) { if (this.field_198036_a.field_71456_v.func_175187_g().func_175262_a()) {
this.field_198036_a.field_71456_v.func_175187_g().func_195621_a((double)(-f1)); this.field_198036_a.field_71456_v.func_175187_g().func_195621_a((double)(-f1));
@@ -168,7 +175,9 @@ @@ -168,7 +176,9 @@
double d2 = (p_198022_3_ - this.field_198040_e) * (double)this.field_198036_a.field_195558_d.func_198107_o() / (double)this.field_198036_a.field_195558_d.func_198105_m(); double d2 = (p_198022_3_ - this.field_198040_e) * (double)this.field_198036_a.field_195558_d.func_198107_o() / (double)this.field_198036_a.field_195558_d.func_198105_m();
double d3 = (p_198022_5_ - this.field_198041_f) * (double)this.field_198036_a.field_195558_d.func_198087_p() / (double)this.field_198036_a.field_195558_d.func_198083_n(); double d3 = (p_198022_5_ - this.field_198041_f) * (double)this.field_198036_a.field_195558_d.func_198087_p() / (double)this.field_198036_a.field_195558_d.func_198083_n();
Screen.wrapScreenError(() -> { Screen.wrapScreenError(() -> {
@ -57,7 +64,7 @@
}, "mouseDragged event handler", iguieventlistener.getClass().getCanonicalName()); }, "mouseDragged event handler", iguieventlistener.getClass().getCanonicalName());
} }
} }
@@ -233,6 +242,10 @@ @@ -233,6 +243,10 @@
return this.field_198039_d; return this.field_198039_d;
} }
@ -68,7 +75,7 @@
public double func_198024_e() { public double func_198024_e() {
return this.field_198040_e; return this.field_198040_e;
} }
@@ -241,6 +254,14 @@ @@ -241,6 +255,14 @@
return this.field_198041_f; return this.field_198041_f;
} }

View file

@ -1038,4 +1038,9 @@ public class ForgeHooksClient
Event event = new InputEvent.MouseScrollEvent(scrollDelta, mouseHelper.isLeftDown(), mouseHelper.isMiddleDown(), mouseHelper.isRightDown(), mouseHelper.getMouseX(), mouseHelper.getMouseY()); Event event = new InputEvent.MouseScrollEvent(scrollDelta, mouseHelper.isLeftDown(), mouseHelper.isMiddleDown(), mouseHelper.isRightDown(), mouseHelper.getMouseX(), mouseHelper.getMouseY());
return MinecraftForge.EVENT_BUS.post(event); return MinecraftForge.EVENT_BUS.post(event);
} }
public static boolean onRawMouseClicked(int button, int action, int mods)
{
return MinecraftForge.EVENT_BUS.post(new InputEvent.RawMouseEvent(button, action, mods));
}
} }

View file

@ -27,6 +27,59 @@ import org.lwjgl.glfw.GLFW;
public class InputEvent extends Event public class InputEvent extends Event
{ {
/**
* A cancellable mouse event fired before key bindings are updated
*/
public static class RawMouseEvent extends InputEvent
{
private final int button;
private final int action;
private final int mods;
public RawMouseEvent(int button, int action, int mods)
{
this.button = button;
this.action = action;
this.mods = mods;
}
/**
* The mouse button that triggered this event.
* https://www.glfw.org/docs/latest/group__buttons.html
*
* @see GLFW mouse constants starting with "GLFW_MOUSE_BUTTON_"
*/
public int getButton()
{
return this.button;
}
/**
* Integer representing the mouse button's action.
*
* @see GLFW#GLFW_PRESS
* @see GLFW#GLFW_RELEASE
*/
public int getAction()
{
return this.action;
}
/**
* Bit field representing the modifier keys pressed.
* https://www.glfw.org/docs/latest/group__mods.html
*
* @see GLFW#GLFW_MOD_SHIFT
* @see GLFW#GLFW_MOD_CONTROL
* @see GLFW#GLFW_MOD_ALT
* @see GLFW#GLFW_MOD_SUPER
*/
public int getMods()
{
return this.mods;
}
}
/** /**
* This event fires when a mouse input is detected. * This event fires when a mouse input is detected.
*/ */