22
33import net .minecraft .client .Minecraft ;
44import net .minecraft .client .gui .GuiScreen ;
5+ import net .minecraftforge .client .event .GuiScreenEvent ;
56
67import com .cleanroommc .modularui .ClientEventHandler ;
78import com .cleanroommc .modularui .api .IMuiScreen ;
89import com .cleanroommc .modularui .core .mixin .GuiScreenAccessor ;
10+ import com .cleanroommc .modularui .screen .ClientScreenHandler ;
11+ import com .cleanroommc .modularui .screen .ModularScreen ;
912import org .lwjgl .input .Keyboard ;
1013import org .lwjgl .input .Mouse ;
1114import org .spongepowered .asm .mixin .Mixin ;
15+ import org .spongepowered .asm .mixin .Unique ;
1216import org .spongepowered .asm .mixin .injection .At ;
17+ import org .spongepowered .asm .mixin .injection .Inject ;
1318import org .spongepowered .asm .mixin .injection .Redirect ;
19+ import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
20+
21+ import java .io .IOException ;
1422
1523@ Mixin (value = ClientEventHandler .class , remap = false )
1624@ SuppressWarnings ("UnstableApiUsage" )
@@ -21,23 +29,32 @@ public abstract class ClientEventHandlerMixin {
2129 private static void fixMouseInput (GuiScreen instance ) {
2230 int button = Mouse .getEventButton ();
2331 if (instance instanceof IMuiScreen screen && instance instanceof GuiScreenAccessor acc ) {
32+ ModularScreen ms = screen .getScreen ();
2433 if (Mouse .getEventButtonState ()) {
2534 acc .setEventButton (button );
2635 acc .setLastMouseEvent (Minecraft .getSystemTime ());
27- screen . getScreen () .onMousePressed (button );
36+ ms .onMousePressed (button );
2837
2938 } else if (button != -1 ) {
3039 acc .setEventButton (-1 );
31- screen . getScreen () .onMouseRelease (button );
40+ ms .onMouseRelease (button );
3241
3342 } else if (acc .getEventButton () != -1 && acc .getLastMouseEvent () > 0L ) {
3443 long l = Minecraft .getSystemTime () - acc .getLastMouseEvent ();
35- screen . getScreen () .onMouseDrag (button , l );
44+ ms .onMouseDrag (button , l );
3645 }
3746 }
3847 }
3948
40- private static Character lastChar = null ;
49+ @ Inject (method = "onGuiInput(Lnet/minecraftforge/client/event/GuiScreenEvent$MouseInputEvent$Pre;)V" ,
50+ at = @ At ("TAIL" ))
51+ private static void fixScrollJei (GuiScreenEvent .MouseInputEvent .Pre event , CallbackInfo ci ) throws IOException {
52+ if (!event .isCanceled ())
53+ ClientScreenHandler .onGuiInputLow (event );
54+ }
55+
56+ @ Unique
57+ private static Character gregTech$lastChar = null ;
4158
4259 @ Redirect (method = "onGuiInput(Lnet/minecraftforge/client/event/GuiScreenEvent$KeyboardInputEvent$Pre;)V" ,
4360 at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/gui/GuiScreen;handleKeyboardInput()V" ))
@@ -47,20 +64,15 @@ private static void fixKeyInput(GuiScreen instance) {
4764 int key = Keyboard .getEventKey ();
4865 boolean state = Keyboard .getEventKeyState ();
4966 if (state ) {
50- lastChar = c0 ;
67+ gregTech$ lastChar = c0 ;
5168 screen .getScreen ().onKeyPressed (c0 , key );
52- // return doAction(muiScreen, ms -> ms.onKeyPressed(c0, key)) || keyTyped(mcScreen, c0, key);
5369 } else {
5470 // releasing a key
5571 // for some reason when you press E after joining a world the button will not trigger the press event,
56- // but ony the release event, causing this to be null
57- if (lastChar == null ) return ;
72+ // but only the release event, causing this to be null
73+ if (gregTech$ lastChar == null ) return ;
5874 // when the key is released, the event char is empty
59- screen .getScreen ().onKeyRelease (lastChar , key );
60- // if (doAction(muiScreen, ms -> ms.onKeyRelease(lastChar, key))) return true;
61- // if (key == 0 && c0 >= ' ') {
62- // return keyTyped(mcScreen, c0, key);
63- // }
75+ screen .getScreen ().onKeyRelease (gregTech$lastChar , key );
6476 }
6577 }
6678 }
0 commit comments