Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 93f1dd8

Browse files
committed
clean up
1 parent 28aed11 commit 93f1dd8

4 files changed

Lines changed: 50 additions & 49 deletions

File tree

patchwork-rendering/src/main/java/com/patchworkmc/mixin/rendering/MixinGameRenderer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ public abstract class MixinGameRenderer {
3939
private MinecraftClient client;
4040

4141
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;render(IIF)V"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
42-
private void beforeRenderScreen(float tickDelta, long startTime, boolean fullRender, CallbackInfo ci, int i, int j) {
43-
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.DrawScreenEvent.Pre(client.currentScreen, i, j, tickDelta))) {
44-
ci.cancel();
42+
private void beforeRenderScreen(float tickDelta, long startTime, boolean fullRender, CallbackInfo info, int mouseX, int mouseY) {
43+
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.DrawScreenEvent.Pre(client.currentScreen, mouseX, mouseY, tickDelta))) {
44+
info.cancel();
4545
}
4646
}
4747

4848
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;render(IIF)V", shift = At.Shift.BY, by = 2), locals = LocalCapture.CAPTURE_FAILHARD)
49-
private void afterRenderScreen(float tickDelta, long startTime, boolean fullRender, CallbackInfo ci, int i, int j) {
50-
MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.DrawScreenEvent.Post(client.currentScreen, i, j, tickDelta));
49+
private void afterRenderScreen(float tickDelta, long startTime, boolean fullRender, CallbackInfo info, int mouseX, int mouseY) {
50+
MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.DrawScreenEvent.Post(client.currentScreen, mouseX, mouseY, tickDelta));
5151
}
5252
}

patchwork-rendering/src/main/java/com/patchworkmc/mixin/rendering/MixinKeyboard.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,56 +38,56 @@ public abstract class MixinKeyboard {
3838
private boolean repeatEvents;
3939

4040
@Inject(method = "method_1454", at = @At("HEAD"), cancellable = true)
41-
private void preKeyEvent(int i, boolean[] bls, ParentElement element, int key, int scanCode, int j, CallbackInfo info) {
41+
private void preKeyEvent(int i, boolean[] bls, ParentElement element, int key, int scanCode, int mods, CallbackInfo info) {
4242
if (i != 1 && (i != 2 || !this.repeatEvents)) {
4343
if (i == 0) {
44-
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardKeyReleasedEvent.Pre((Screen) element, key, scanCode, j))) {
44+
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardKeyReleasedEvent.Pre((Screen) element, key, scanCode, mods))) {
4545
bls[0] = true;
4646
info.cancel();
4747
}
4848
}
4949
} else {
50-
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardKeyPressedEvent.Pre((Screen) element, key, scanCode, j))) {
50+
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardKeyPressedEvent.Pre((Screen) element, key, scanCode, mods))) {
5151
bls[0] = true;
5252
info.cancel();
5353
}
5454
}
5555
}
5656

5757
@Inject(method = "method_1454", at = @At("RETURN"))
58-
private void postKeyEvent(int i, boolean[] bls, ParentElement element, int key, int scanCode, int j, CallbackInfo info) {
58+
private void postKeyEvent(int i, boolean[] bls, ParentElement element, int key, int scanCode, int mods, CallbackInfo info) {
5959
if (bls[0]) {
6060
return;
6161
}
6262

6363
if (i != 1 && (i != 2 || !this.repeatEvents)) {
6464
if (i == 0) {
65-
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardKeyReleasedEvent.Post((Screen) element, key, scanCode, j))) {
65+
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardKeyReleasedEvent.Post((Screen) element, key, scanCode, mods))) {
6666
bls[0] = true;
6767
}
6868
}
6969
} else {
70-
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardKeyPressedEvent.Post((Screen) element, key, scanCode, j))) {
70+
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardKeyPressedEvent.Post((Screen) element, key, scanCode, mods))) {
7171
bls[0] = true;
7272
}
7373
}
7474
}
7575

7676
@Inject(method = "method_1458", at = @At("HEAD"), cancellable = true)
77-
private static void charEvent(Element element, int i, int j, CallbackInfo info) {
78-
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardCharTypedEvent.Pre((Screen) element, (char) i, j))) {
77+
private static void charEvent(Element element, int character, int mods, CallbackInfo info) {
78+
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardCharTypedEvent.Pre((Screen) element, (char) character, mods))) {
7979
info.cancel();
80-
} else if (!element.charTyped((char) i, j)) {
81-
MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardCharTypedEvent.Post((Screen) element, (char) i, j));
80+
} else if (!element.charTyped((char) character, mods)) {
81+
MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardCharTypedEvent.Post((Screen) element, (char) character, mods));
8282
}
8383
}
8484

8585
@Inject(method = "method_1473", at = @At("HEAD"), cancellable = true)
86-
private static void charEvent(Element element, char i, int j, CallbackInfo info) {
87-
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardCharTypedEvent.Pre((Screen) element, i, j))) {
86+
private static void charEvent(Element element, char character, int mods, CallbackInfo info) {
87+
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardCharTypedEvent.Pre((Screen) element, character, mods))) {
8888
info.cancel();
89-
} else if (!element.charTyped(i, j)) {
90-
MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardCharTypedEvent.Post((Screen) element, i, j));
89+
} else if (!element.charTyped(character, mods)) {
90+
MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardCharTypedEvent.Post((Screen) element, character, mods));
9191
}
9292
}
9393
}

patchwork-rendering/src/main/java/com/patchworkmc/mixin/rendering/MixinMouse.java

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import net.minecraft.client.MinecraftClient;
3333
import net.minecraft.client.Mouse;
3434
import net.minecraft.client.gui.Element;
35+
import net.minecraft.client.gui.screen.Screen;
3536

3637
@Mixin(Mouse.class)
3738
public abstract class MixinMouse {
@@ -52,71 +53,71 @@ public abstract class MixinMouse {
5253
private double cursorDeltaX;
5354

5455
@Inject(method = "method_1611", at = @At("HEAD"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
55-
public void preMouseClicked(boolean[] bls, double d, double e, int button, CallbackInfo info) {
56-
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseClickedEvent.Pre(client.currentScreen, d, e, button))) {
57-
bls[0] = true;
56+
public void preMouseClicked(boolean[] handled, double mouseX, double mouseY, int button, CallbackInfo info) {
57+
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseClickedEvent.Pre(client.currentScreen, mouseX, mouseY, button))) {
58+
handled[0] = true;
5859
info.cancel();
5960
}
6061
}
6162

6263
@Inject(method = "method_1611", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
63-
private void postMouseClicked(boolean[] bls, double d, double e, int button, CallbackInfo info) {
64-
if (bls[0]) {
64+
private void postMouseClicked(boolean[] handled, double mouseX, double mouseY, int button, CallbackInfo info) {
65+
if (handled[0]) {
6566
return;
6667
}
6768

68-
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseClickedEvent.Post(client.currentScreen, d, e, button))) {
69-
bls[0] = true;
69+
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseClickedEvent.Post(client.currentScreen, mouseX, mouseY, button))) {
70+
handled[0] = true;
7071
info.cancel();
7172
}
7273
}
7374

7475
@Inject(method = "method_1605", at = @At("HEAD"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
75-
private void preMouseReleased(boolean[] bls, double d, double e, int button, CallbackInfo info) {
76-
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseReleasedEvent.Pre(client.currentScreen, d, e, button))) {
77-
bls[0] = true;
76+
private void preMouseReleased(boolean[] handled, double mouseX, double mouseY, int button, CallbackInfo info) {
77+
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseReleasedEvent.Pre(client.currentScreen, mouseX, mouseY, button))) {
78+
handled[0] = true;
7879
info.cancel();
7980
}
8081
}
8182

8283
@Inject(method = "method_1605", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILHARD)
83-
private void postMouseReleased(boolean[] bls, double d, double e, int button, CallbackInfo info) {
84-
if (bls[0]) {
84+
private void postMouseReleased(boolean[] handled, double mouseX, double mouseY, int button, CallbackInfo info) {
85+
if (handled[0]) {
8586
return;
8687
}
8788

88-
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseReleasedEvent.Post(client.currentScreen, d, e, button))) {
89-
bls[0] = true;
89+
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseReleasedEvent.Post(client.currentScreen, mouseX, mouseY, button))) {
90+
handled[0] = true;
9091
info.cancel();
9192
}
9293
}
9394

9495
@Inject(method = "method_1602", at = @At("HEAD"), cancellable = true)
95-
private void preMouseDragged(Element element, double d, double e, double f, double g, CallbackInfo info) {
96-
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseDragEvent.Pre(client.currentScreen, d, e, activeButton, f, g))) {
96+
private void preMouseDragged(Element element, double mouseX, double mouseY, double deltaX, double deltaY, CallbackInfo info) {
97+
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseDragEvent.Pre((Screen) element, mouseX, mouseY, activeButton, deltaX, deltaY))) {
9798
info.cancel();
9899
}
99100
}
100101

101102
@Inject(method = "method_1602", at = @At("RETURN"))
102-
private void postMouseDragged(Element element, double d, double e, double f, double g, CallbackInfo info) {
103-
MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseDragEvent.Post(client.currentScreen, d, e, activeButton, f, g));
103+
private void postMouseDragged(Element element, double mouseX, double mouseY, double deltaX, double deltaY, CallbackInfo info) {
104+
MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseDragEvent.Post((Screen) element, mouseX, mouseY, activeButton, deltaX, deltaY));
104105
}
105106

106107
@Inject(method = "onMouseScroll", at = @At(value = "INVOKE",
107108
target = "Lnet/minecraft/client/gui/screen/Screen;mouseScrolled(DDD)Z",
108109
ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
109-
private void preMouseScrolled(long window, double d, double e, CallbackInfo ci, double f, double g, double h) {
110-
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseScrollEvent.Pre(client.currentScreen, g, h, f))) {
111-
ci.cancel();
110+
private void preMouseScrolled(long window, double xOffset, double yOffset, CallbackInfo info, double amount, double mouseX, double mouseY) {
111+
if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseScrollEvent.Pre(client.currentScreen, mouseX, mouseY, amount))) {
112+
info.cancel();
112113
}
113114
}
114115

115116
@Inject(method = "onMouseScroll", at = @At(value = "INVOKE",
116117
target = "Lnet/minecraft/client/gui/screen/Screen;mouseScrolled(DDD)Z",
117118
ordinal = 0, shift = At.Shift.BY, by = 2), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
118-
private void postMouseScrolled(long window, double d, double e, CallbackInfo ci, double f, double g, double h) {
119-
MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseScrollEvent.Post(client.currentScreen, g, h, f));
119+
private void postMouseScrolled(long window, double xOffset, double yOffset, CallbackInfo info, double amount, double mouseX, double mouseY) {
120+
MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseScrollEvent.Post(client.currentScreen, mouseX, mouseY, amount));
120121
}
121122

122123
public boolean isMiddleDown() {

patchwork-rendering/src/main/java/net/minecraftforge/client/event/GuiScreenEvent.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public GuiScreenEvent(Screen gui) {
5555
}
5656

5757
/**
58-
* The Screen object generating this event.
58+
* The {@link Screen} object generating this event.
5959
*/
6060
public Screen getGui() {
6161
return gui;
@@ -98,9 +98,9 @@ public void removeWidget(AbstractButtonWidget button) {
9898
* {@link Screen#width}, and {@link Screen#height}.</p>
9999
*
100100
* <p>If canceled the following lines are skipped in {@link Screen#init(net.minecraft.client.MinecraftClient, int, int)}:</p>
101-
* {@code this.buttons.clear();}<br/>
102-
* {@code this.children.clear();}<br/>
103-
* {@code this.init();}<br/>
101+
* <p>{@code this.buttons.clear();}</p>
102+
* <p>{@code this.children.clear();}</p>
103+
* <p>{@code this.init();}</p>
104104
*/
105105
public static class Pre extends InitGuiEvent {
106106
// For EventBus
@@ -263,7 +263,7 @@ public void setButton(ButtonWidget button) {
263263
}
264264

265265
/**
266-
* A COPY of the {@link #buttonList} field from the GuiScreen referenced by {@link #gui}.
266+
* A COPY of the {@link #buttonList} field from {@link Screen#buttons} referenced by {@link #gui}.
267267
*/
268268
public List<ButtonWidget> getButtonList() {
269269
return buttonList;
@@ -274,7 +274,7 @@ public void setButtonList(List<ButtonWidget> buttonList) {
274274
}
275275

276276
/**
277-
* This event fires once it has been determined that a GuiButton object has been clicked.
277+
* This event fires once it has been determined that a {@link ButtonWidget} object has been clicked.
278278
* Replace button with a different button from buttonList to have that button's action executed.
279279
*/
280280
public static class Pre extends ActionPerformedEvent {
@@ -543,7 +543,7 @@ public boolean isCancelable() {
543543
}
544544

545545
/**
546-
* This event fires after {@link Element#mouseScrolled(double)} if the scroll was not already handled.
546+
* This event fires after {@link Element#mouseScrolled(double, double, double)} if the scroll was not already handled.
547547
* Cancel this event when you successfully use the mouse scroll, to prevent other handlers from using the same input.
548548
*/
549549
public static class Post extends MouseScrollEvent {

0 commit comments

Comments
 (0)