// Path: src/main/java/de/johni0702/minecraft/gui/utils/EventRegistrations.java
// public class EventRegistrations {
//     //#if MC<=11302
//     //$$ static { new EventsAdapter().register(); }
//     //#endif
// 
//     private List<EventRegistration<?>> registrations = new ArrayList<>();
// 
//     public <T> EventRegistrations on(EventRegistration<T> registration) {
//         registrations.add(registration);
//         return this;
//     }
// 
//     public <T> EventRegistrations on(Event<T> event, T listener) {
//         return on(EventRegistration.create(event, listener));
//     }
// 
//     public void register() {
//         //#if MC<=11302
//         //$$ MinecraftForge.EVENT_BUS.register(this);
//         //#endif
//         //#if MC<10809
//         //$$ FMLCommonHandler.instance().bus().register(this);
//         //#endif
//         for (EventRegistration<?> registration : registrations) {
//             registration.register();
//         }
//     }
// 
//     public void unregister() {
//         //#if MC<=11302
//         //$$ MinecraftForge.EVENT_BUS.unregister(this);
//         //#endif
//         //#if MC<10809
//         //$$ FMLCommonHandler.instance().bus().unregister(this);
//         //#endif
//         for (EventRegistration<?> registration : registrations) {
//             registration.unregister();
//         }
//     }
// }
// 
// Path: versions/1.14.4/src/main/java/de/johni0702/minecraft/gui/versions/MatrixStack.java
// public class MatrixStack {
// }
// 
// Path: src/main/java/de/johni0702/minecraft/gui/versions/callbacks/InitScreenCallback.java
// public interface InitScreenCallback {
//     Event<InitScreenCallback> EVENT = Event.create((listeners) ->
//             (screen, buttons) -> {
//                 for (InitScreenCallback listener : listeners) {
//                     listener.initScreen(screen, buttons);
//                 }
//             }
//     );
// 
//     void initScreen(Screen screen, Collection<AbstractButtonWidget> buttons);
// 
//     interface Pre {
//         Event<InitScreenCallback.Pre> EVENT = Event.create((listeners) ->
//                 (screen) -> {
//                     for (InitScreenCallback.Pre listener : listeners) {
//                         listener.preInitScreen(screen);
//                     }
//                 }
//         );
// 
//         void preInitScreen(Screen screen);
//     }
// }
// 
// 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/PostRenderScreenCallback.java
// public interface PostRenderScreenCallback {
//     Event<PostRenderScreenCallback> EVENT = Event.create((listeners) ->
//             (stack, partialTicks) -> {
//                 for (PostRenderScreenCallback listener : listeners) {
//                     listener.postRenderScreen(stack, partialTicks);
//                 }
//             }
//     );
// 
//     void postRenderScreen(MatrixStack stack, float partialTicks);
// }
// 
// 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/callbacks/RenderHudCallback.java
// public interface RenderHudCallback {
//     Event<RenderHudCallback> EVENT = Event.create((listeners) ->
//             (stack, partialTicks) -> {
//                 for (RenderHudCallback listener : listeners) {
//                     listener.renderHud(stack, partialTicks);
//                 }
//             }
//     );
// 
//     void renderHud(MatrixStack stack, float partialTicks);
// }


import de.johni0702.minecraft.gui.utils.EventRegistrations;
import de.johni0702.minecraft.gui.versions.MatrixStack;
import de.johni0702.minecraft.gui.versions.callbacks.InitScreenCallback;
import de.johni0702.minecraft.gui.versions.callbacks.OpenGuiScreenCallback;
import de.johni0702.minecraft.gui.versions.callbacks.PostRenderScreenCallback;
import de.johni0702.minecraft.gui.versions.callbacks.PreTickCallback;
import de.johni0702.minecraft.gui.versions.callbacks.RenderHudCallback;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import java.util.List;
                //$$ event.gui
                //#endif
        );
    }

    public static float getPartialTicks(RenderGameOverlayEvent event) {
        //#if MC>=10904
        return event.getPartialTicks();
        //#else
        //$$ return event.partialTicks;
        //#endif
    }

    public static float getPartialTicks(GuiScreenEvent.DrawScreenEvent.Post event) {
        //#if MC>=10904
        return event.getRenderPartialTicks();
        //#else
        //$$ return event.renderPartialTicks;
        //#endif
    }

    @SubscribeEvent
    public void onGuiRender(GuiScreenEvent.DrawScreenEvent.Post event) {
        PostRenderScreenCallback.EVENT.invoker().postRenderScreen(new MatrixStack(), getPartialTicks(event));
    }

    // Even when event was cancelled cause Lunatrius' InGame-Info-XML mod cancels it and we don't actually care about
    // the event (i.e. the overlay text), just about when it's called.
    @SubscribeEvent(receiveCanceled = true)
    public void renderOverlay(RenderGameOverlayEvent.Text event) {
// Path: src/main/java/de/johni0702/minecraft/gui/utils/EventRegistrations.java
// public class EventRegistrations {
//     //#if MC<=11302
//     //$$ static { new EventsAdapter().register(); }
//     //#endif
// 
//     private List<EventRegistration<?>> registrations = new ArrayList<>();
// 
//     public <T> EventRegistrations on(EventRegistration<T> registration) {
//         registrations.add(registration);
//         return this;
//     }
// 
//     public <T> EventRegistrations on(Event<T> event, T listener) {
//         return on(EventRegistration.create(event, listener));
//     }
// 
//     public void register() {
//         //#if MC<=11302
//         //$$ MinecraftForge.EVENT_BUS.register(this);
//         //#endif
//         //#if MC<10809
//         //$$ FMLCommonHandler.instance().bus().register(this);
//         //#endif
//         for (EventRegistration<?> registration : registrations) {
//             registration.register();
//         }
//     }
// 
//     public void unregister() {
//         //#if MC<=11302
//         //$$ MinecraftForge.EVENT_BUS.unregister(this);
//         //#endif
//         //#if MC<10809
//         //$$ FMLCommonHandler.instance().bus().unregister(this);
//         //#endif
//         for (EventRegistration<?> registration : registrations) {
//             registration.unregister();
//         }
//     }
// }
// 
// Path: versions/1.14.4/src/main/java/de/johni0702/minecraft/gui/versions/MatrixStack.java
// public class MatrixStack {
// }
// 
// Path: src/main/java/de/johni0702/minecraft/gui/versions/callbacks/InitScreenCallback.java
// public interface InitScreenCallback {
//     Event<InitScreenCallback> EVENT = Event.create((listeners) ->
//             (screen, buttons) -> {
//                 for (InitScreenCallback listener : listeners) {
//                     listener.initScreen(screen, buttons);
//                 }
//             }
//     );
// 
//     void initScreen(Screen screen, Collection<AbstractButtonWidget> buttons);
// 
//     interface Pre {
//         Event<InitScreenCallback.Pre> EVENT = Event.create((listeners) ->
//                 (screen) -> {
//                     for (InitScreenCallback.Pre listener : listeners) {
//                         listener.preInitScreen(screen);
//                     }
//                 }
//         );
// 
//         void preInitScreen(Screen screen);
//     }
// }
// 
// 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/PostRenderScreenCallback.java
// public interface PostRenderScreenCallback {
//     Event<PostRenderScreenCallback> EVENT = Event.create((listeners) ->
//             (stack, partialTicks) -> {
//                 for (PostRenderScreenCallback listener : listeners) {
//                     listener.postRenderScreen(stack, partialTicks);
//                 }
//             }
//     );
// 
//     void postRenderScreen(MatrixStack stack, float partialTicks);
// }
// 
// 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/callbacks/RenderHudCallback.java
// public interface RenderHudCallback {
//     Event<RenderHudCallback> EVENT = Event.create((listeners) ->
//             (stack, partialTicks) -> {
//                 for (RenderHudCallback listener : listeners) {
//                     listener.renderHud(stack, partialTicks);
//                 }
//             }
//     );
// 
//     void renderHud(MatrixStack stack, float partialTicks);
// }


// Path: versions/1.12/src/main/java/de/johni0702/minecraft/gui/versions/forge/EventsAdapter.java
import de.johni0702.minecraft.gui.utils.EventRegistrations;
import de.johni0702.minecraft.gui.versions.MatrixStack;
import de.johni0702.minecraft.gui.versions.callbacks.InitScreenCallback;
import de.johni0702.minecraft.gui.versions.callbacks.OpenGuiScreenCallback;
import de.johni0702.minecraft.gui.versions.callbacks.PostRenderScreenCallback;
import de.johni0702.minecraft.gui.versions.callbacks.PreTickCallback;
import de.johni0702.minecraft.gui.versions.callbacks.RenderHudCallback;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import java.util.List;

                //$$ event.gui
                //#endif
        );
    }

    public static float getPartialTicks(RenderGameOverlayEvent event) {
        //#if MC>=10904
        return event.getPartialTicks();
        //#else
        //$$ return event.partialTicks;
        //#endif
    }

    public static float getPartialTicks(GuiScreenEvent.DrawScreenEvent.Post event) {
        //#if MC>=10904
        return event.getRenderPartialTicks();
        //#else
        //$$ return event.renderPartialTicks;
        //#endif
    }

    @SubscribeEvent
    public void onGuiRender(GuiScreenEvent.DrawScreenEvent.Post event) {
        PostRenderScreenCallback.EVENT.invoker().postRenderScreen(new MatrixStack(), getPartialTicks(event));
    }

    // Even when event was cancelled cause Lunatrius' InGame-Info-XML mod cancels it and we don't actually care about
    // the event (i.e. the overlay text), just about when it's called.
    @SubscribeEvent(receiveCanceled = true)
    public void renderOverlay(RenderGameOverlayEvent.Text event) {
        RenderHudCallback.EVENT.invoker().renderHud(new MatrixStack(), getPartialTicks(event));