// Path: src/main/java/de/johni0702/minecraft/gui/versions/callbacks/KeyboardCallback.java
// public interface KeyboardCallback {
//     Event<KeyboardCallback> EVENT = Event.create((listeners) ->
//             new KeyboardCallback() {
//                 @Override
//                 public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
//                     for (KeyboardCallback listener : listeners) {
//                         if (listener.keyPressed(keyCode, scanCode, modifiers)) {
//                             return true;
//                         }
//                     }
//                     return false;
//                 }
// 
//                 @Override
//                 public boolean keyReleased(int keyCode, int scanCode, int modifiers) {
//                     for (KeyboardCallback listener : listeners) {
//                         if (listener.keyReleased(keyCode, scanCode, modifiers)) {
//                             return true;
//                         }
//                     }
//                     return false;
//                 }
// 
//                 @Override
//                 public boolean charTyped(char charCode, int scanCode) {
//                     for (KeyboardCallback listener : listeners) {
//                         if (listener.charTyped(charCode, scanCode)) {
//                             return true;
//                         }
//                     }
//                     return false;
//                 }
//             }
//     );
// 
//     boolean keyPressed(int keyCode, int scanCode, int modifiers);
//     boolean keyReleased(int keyCode, int scanCode, int modifiers);
//     boolean charTyped(char keyChar, int scanCode);
// }


import de.johni0702.minecraft.gui.versions.callbacks.KeyboardCallback;
import net.minecraft.client.Keyboard;
import net.minecraft.client.gui.Element;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Group;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.client.gui.ParentElement;
//#if FABRIC>=1
package de.johni0702.minecraft.gui.versions.mixin;


//#if MC>=11700
//$$ import net.minecraft.client.gui.screen.Screen;
//#else
//#endif

@Mixin(Keyboard.class)
public class MixinKeyboardListener {
    @Inject(
            method = "method_1454",
            //#if MC>=11700
            //$$ at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;keyPressed(III)Z"),
            //#else
            at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ParentElement;keyPressed(III)Z"),
            //#endif
            cancellable = true
    )
    //#if MC>=11700
    //$$ private void keyPressed(int i, Screen screen, boolean[] bls, int keyCode, int scanCode, int modifiers, CallbackInfo ci) {
    //#else
    private void keyPressed(int i, boolean[] bls, ParentElement element, int keyCode, int scanCode, int modifiers, CallbackInfo ci) {
    //#endif
// Path: src/main/java/de/johni0702/minecraft/gui/versions/callbacks/KeyboardCallback.java
// public interface KeyboardCallback {
//     Event<KeyboardCallback> EVENT = Event.create((listeners) ->
//             new KeyboardCallback() {
//                 @Override
//                 public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
//                     for (KeyboardCallback listener : listeners) {
//                         if (listener.keyPressed(keyCode, scanCode, modifiers)) {
//                             return true;
//                         }
//                     }
//                     return false;
//                 }
// 
//                 @Override
//                 public boolean keyReleased(int keyCode, int scanCode, int modifiers) {
//                     for (KeyboardCallback listener : listeners) {
//                         if (listener.keyReleased(keyCode, scanCode, modifiers)) {
//                             return true;
//                         }
//                     }
//                     return false;
//                 }
// 
//                 @Override
//                 public boolean charTyped(char charCode, int scanCode) {
//                     for (KeyboardCallback listener : listeners) {
//                         if (listener.charTyped(charCode, scanCode)) {
//                             return true;
//                         }
//                     }
//                     return false;
//                 }
//             }
//     );
// 
//     boolean keyPressed(int keyCode, int scanCode, int modifiers);
//     boolean keyReleased(int keyCode, int scanCode, int modifiers);
//     boolean charTyped(char keyChar, int scanCode);
// }


// Path: src/main/java/de/johni0702/minecraft/gui/versions/mixin/MixinKeyboardListener.java
import de.johni0702.minecraft.gui.versions.callbacks.KeyboardCallback;
import net.minecraft.client.Keyboard;
import net.minecraft.client.gui.Element;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Group;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.client.gui.ParentElement;

//#if FABRIC>=1
package de.johni0702.minecraft.gui.versions.mixin;


//#if MC>=11700
//$$ import net.minecraft.client.gui.screen.Screen;
//#else
//#endif

@Mixin(Keyboard.class)
public class MixinKeyboardListener {
    @Inject(
            method = "method_1454",
            //#if MC>=11700
            //$$ at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;keyPressed(III)Z"),
            //#else
            at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ParentElement;keyPressed(III)Z"),
            //#endif
            cancellable = true
    )
    //#if MC>=11700
    //$$ private void keyPressed(int i, Screen screen, boolean[] bls, int keyCode, int scanCode, int modifiers, CallbackInfo ci) {
    //#else
    private void keyPressed(int i, boolean[] bls, ParentElement element, int keyCode, int scanCode, int modifiers, CallbackInfo ci) {
    //#endif
        if (KeyboardCallback.EVENT.invoker().keyPressed(keyCode, scanCode, modifiers)) {