11package works .nuty .calcite .mixin .client ;
22
3+ import com .mojang .brigadier .suggestion .Suggestion ;
34import net .fabricmc .api .EnvType ;
45import net .fabricmc .api .Environment ;
56import net .minecraft .client .gui .screen .ChatInputSuggestor ;
67import org .lwjgl .glfw .GLFW ;
78import org .spongepowered .asm .mixin .Mixin ;
89import org .spongepowered .asm .mixin .Shadow ;
10+ import org .spongepowered .asm .mixin .Unique ;
911import org .spongepowered .asm .mixin .injection .At ;
1012import org .spongepowered .asm .mixin .injection .Inject ;
13+ import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
1114import org .spongepowered .asm .mixin .injection .callback .CallbackInfoReturnable ;
1215
16+ import java .util .List ;
17+
1318@ Environment (EnvType .CLIENT )
1419@ Mixin (ChatInputSuggestor .SuggestionWindow .class )
1520public abstract class SuggestionWindowMixin {
@@ -22,6 +27,13 @@ public abstract class SuggestionWindowMixin {
2227 @ Shadow
2328 public abstract void complete ();
2429
30+ @ Unique boolean chatScreenSized ;
31+
32+ @ Inject (at = @ At ("TAIL" ), method = "<init>" )
33+ public void init (ChatInputSuggestor chatInputSuggestor , int x , int y , int width , List <Suggestion > suggestions , boolean narrateFirstSuggestion , CallbackInfo ci ) {
34+ this .chatScreenSized = ((ChatInputSuggestorFields ) chatInputSuggestor ).getChatScreenSized ();
35+ }
36+
2537 @ Inject (at = @ At ("HEAD" ), method = "keyPressed" , cancellable = true )
2638 public void keyPressed (int keyCode , int scanCode , int modifiers , CallbackInfoReturnable <Boolean > cir ) {
2739 if ((modifiers & GLFW .GLFW_MOD_CONTROL ) > 0 && keyCode == GLFW .GLFW_KEY_N ) {
@@ -36,7 +48,7 @@ public void keyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoRet
3648 cir .setReturnValue (true );
3749 cir .cancel ();
3850 }
39- if (keyCode == GLFW .GLFW_KEY_ENTER || keyCode == GLFW .GLFW_KEY_KP_ENTER ) {
51+ if (! chatScreenSized && ( keyCode == GLFW .GLFW_KEY_ENTER || keyCode == GLFW .GLFW_KEY_KP_ENTER ) ) {
4052 this .complete ();
4153 cir .setReturnValue (true );
4254 cir .cancel ();
0 commit comments