// Path: src/main/java/de/johni0702/minecraft/gui/versions/callbacks/MouseCallback.java
// public interface MouseCallback {
//     Event<MouseCallback> EVENT = Event.create((listeners) ->
//             new MouseCallback() {
//                 @Override
//                 public boolean mouseDown(double x, double y, int button) {
//                     for (MouseCallback listener : listeners) {
//                         if (listener.mouseDown(x, y, button)) {
//                             return true;
//                         }
//                     }
//                     return false;
//                 }
// 
//                 @Override
//                 public boolean mouseDrag(double x, double y, int button, double dx, double dy) {
//                     for (MouseCallback listener : listeners) {
//                         if (listener.mouseDrag(x, y, button, dx, dy)) {
//                             return true;
//                         }
//                     }
//                     return false;
//                 }
// 
//                 @Override
//                 public boolean mouseUp(double x, double y, int button) {
//                     for (MouseCallback listener : listeners) {
//                         if (listener.mouseUp(x, y, button)) {
//                             return true;
//                         }
//                     }
//                     return false;
//                 }
// 
//                 @Override
//                 public boolean mouseScroll(double x, double y, double scroll) {
//                     for (MouseCallback listener : listeners) {
//                         if (listener.mouseScroll(x, y, scroll)) {
//                             return true;
//                         }
//                     }
//                     return false;
//                 }
//             }
//     );
// 
//     boolean mouseDown(double x, double y, int button);
//     boolean mouseDrag(double x, double y, int button, double dx, double dy);
//     boolean mouseUp(double x, double y, int button);
//     boolean mouseScroll(double x, double y, double scroll);
// }


import de.johni0702.minecraft.gui.versions.callbacks.MouseCallback;
import net.minecraft.client.Mouse;
import net.minecraft.client.gui.screen.Screen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.client.gui.Element;
//#if FABRIC>=1
package de.johni0702.minecraft.gui.versions.mixin;


//#if MC>=11700
//#else
//#endif

@Mixin(Mouse.class)
public abstract class MixinMouseListener {
    @Accessor // Note: for some reason Mixin doesn't include this in the refmap json if it's just a @Shadow field
    abstract int getActiveButton();

    @Inject(method = "method_1611", at = @At("HEAD"), cancellable = true)
    //#if MC>=11700
    //$$ private static void mouseDown(boolean[] result, Screen screen, double x, double y, int button, CallbackInfo ci) {
    //#else
    private void mouseDown(boolean[] result, double x, double y, int button, CallbackInfo ci) {
    //#endif
// Path: src/main/java/de/johni0702/minecraft/gui/versions/callbacks/MouseCallback.java
// public interface MouseCallback {
//     Event<MouseCallback> EVENT = Event.create((listeners) ->
//             new MouseCallback() {
//                 @Override
//                 public boolean mouseDown(double x, double y, int button) {
//                     for (MouseCallback listener : listeners) {
//                         if (listener.mouseDown(x, y, button)) {
//                             return true;
//                         }
//                     }
//                     return false;
//                 }
// 
//                 @Override
//                 public boolean mouseDrag(double x, double y, int button, double dx, double dy) {
//                     for (MouseCallback listener : listeners) {
//                         if (listener.mouseDrag(x, y, button, dx, dy)) {
//                             return true;
//                         }
//                     }
//                     return false;
//                 }
// 
//                 @Override
//                 public boolean mouseUp(double x, double y, int button) {
//                     for (MouseCallback listener : listeners) {
//                         if (listener.mouseUp(x, y, button)) {
//                             return true;
//                         }
//                     }
//                     return false;
//                 }
// 
//                 @Override
//                 public boolean mouseScroll(double x, double y, double scroll) {
//                     for (MouseCallback listener : listeners) {
//                         if (listener.mouseScroll(x, y, scroll)) {
//                             return true;
//                         }
//                     }
//                     return false;
//                 }
//             }
//     );
// 
//     boolean mouseDown(double x, double y, int button);
//     boolean mouseDrag(double x, double y, int button, double dx, double dy);
//     boolean mouseUp(double x, double y, int button);
//     boolean mouseScroll(double x, double y, double scroll);
// }


// Path: src/main/java/de/johni0702/minecraft/gui/versions/mixin/MixinMouseListener.java
import de.johni0702.minecraft.gui.versions.callbacks.MouseCallback;
import net.minecraft.client.Mouse;
import net.minecraft.client.gui.screen.Screen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.client.gui.Element;

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


//#if MC>=11700
//#else
//#endif

@Mixin(Mouse.class)
public abstract class MixinMouseListener {
    @Accessor // Note: for some reason Mixin doesn't include this in the refmap json if it's just a @Shadow field
    abstract int getActiveButton();

    @Inject(method = "method_1611", at = @At("HEAD"), cancellable = true)
    //#if MC>=11700
    //$$ private static void mouseDown(boolean[] result, Screen screen, double x, double y, int button, CallbackInfo ci) {
    //#else
    private void mouseDown(boolean[] result, double x, double y, int button, CallbackInfo ci) {
    //#endif
        if (MouseCallback.EVENT.invoker().mouseDown(x, y, button)) {