// Path: src/main/java/de/johni0702/minecraft/gui/versions/callbacks/OpenGuiScreenCallback.java
// public interface OpenGuiScreenCallback {
//     Event<OpenGuiScreenCallback> EVENT = Event.create((listeners) ->
//             (screen) -> {
//                 for (OpenGuiScreenCallback listener : listeners) {
//                     listener.openGuiScreen(screen);
//                 }
//             }
//     );
// 
//     void openGuiScreen(Screen screen);
// }
// 
// Path: src/main/java/de/johni0702/minecraft/gui/versions/callbacks/PreTickCallback.java
// public interface PreTickCallback {
//     Event<PreTickCallback> EVENT = Event.create((listeners) ->
//             () -> {
//                 for (PreTickCallback listener : listeners) {
//                     listener.preTick();
//                 }
//             }
//     );
// 
//     void preTick();
// }


import de.johni0702.minecraft.gui.versions.callbacks.OpenGuiScreenCallback;
import de.johni0702.minecraft.gui.versions.callbacks.PreTickCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
// Note: this will also work in 1.13 but we don't really support 1.13 and MixinGradle is yet to be updated
//#if FABRIC>=1
package de.johni0702.minecraft.gui.versions.mixin;


@Mixin(MinecraftClient.class)
public abstract class MixinMinecraft {
    @Inject(method = "tick", at = @At("HEAD"))
    private void preTick(CallbackInfo ci) {
        PreTickCallback.EVENT.invoker().preTick();
    }

    @Inject(method = "openScreen", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;"))
    private void openGuiScreen(Screen newGuiScreen, CallbackInfo ci) {
// Path: src/main/java/de/johni0702/minecraft/gui/versions/callbacks/OpenGuiScreenCallback.java
// public interface OpenGuiScreenCallback {
//     Event<OpenGuiScreenCallback> EVENT = Event.create((listeners) ->
//             (screen) -> {
//                 for (OpenGuiScreenCallback listener : listeners) {
//                     listener.openGuiScreen(screen);
//                 }
//             }
//     );
// 
//     void openGuiScreen(Screen screen);
// }
// 
// Path: src/main/java/de/johni0702/minecraft/gui/versions/callbacks/PreTickCallback.java
// public interface PreTickCallback {
//     Event<PreTickCallback> EVENT = Event.create((listeners) ->
//             () -> {
//                 for (PreTickCallback listener : listeners) {
//                     listener.preTick();
//                 }
//             }
//     );
// 
//     void preTick();
// }


// Path: src/main/java/de/johni0702/minecraft/gui/versions/mixin/MixinMinecraft.java
import de.johni0702.minecraft.gui.versions.callbacks.OpenGuiScreenCallback;
import de.johni0702.minecraft.gui.versions.callbacks.PreTickCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

// Note: this will also work in 1.13 but we don't really support 1.13 and MixinGradle is yet to be updated
//#if FABRIC>=1
package de.johni0702.minecraft.gui.versions.mixin;


@Mixin(MinecraftClient.class)
public abstract class MixinMinecraft {
    @Inject(method = "tick", at = @At("HEAD"))
    private void preTick(CallbackInfo ci) {
        PreTickCallback.EVENT.invoker().preTick();
    }

    @Inject(method = "openScreen", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;"))
    private void openGuiScreen(Screen newGuiScreen, CallbackInfo ci) {
        OpenGuiScreenCallback.EVENT.invoker().openGuiScreen(newGuiScreen);