package de.fullrisk.citrusDev.client;

import de.fullrisk.citrusDev.UI.MyScreen;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keymapping.v1.KeyMappingHelper;
import net.minecraft.client.KeyMapping;
import net.minecraft.resources.Identifier;
import org.lwjgl.glfw.GLFW;

public class CitrusDevClient implements ClientModInitializer {

    private static KeyMapping openScreenKey;

    @Override
    public void onInitializeClient() {
        KeyMapping.Category category = KeyMapping.Category.register(
                Identifier.fromNamespaceAndPath("citrus-dev", "general"));

        openScreenKey = KeyMappingHelper.registerKeyMapping(new KeyMapping(
                "key.citrus-dev.open_screen",
                GLFW.GLFW_KEY_G,
                category
        ));

        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            while (openScreenKey.consumeClick()) {
                client.setScreen(new MyScreen());
            }
        });
    }
}