package net.moonleay.gimble.client

import net.fabricmc.api.ClientModInitializer
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
import net.moonleay.gimble.build.BuildConstants
import net.moonleay.gimble.client.keybindings.KeybindingManager
import net.moonleay.gimble.client.keybindings.KeybindingRegistrar
import net.moonleay.gimble.networking.GimbleClient
import org.apache.logging.log4j.LogManager

internal object ClientMain : ClientModInitializer {
    private val LOGGER = LogManager.getLogger(BuildConstants.modName)


    override fun onInitializeClient() {
        LOGGER.info("Initializing Gimble on the client side...")
        KeybindingRegistrar.registerKeybindings()
        registerEvents()
        LOGGER.info("Registering packets...")
        GimbleClient.registerPacketHandlers()
        LOGGER.info("Packets have been registered.")
        LOGGER.info("Gimble has been initialized on the client side.")
    }

    private fun registerEvents() {
        LOGGER.info("Registering client events...")
        ClientTickEvents.END_CLIENT_TICK.register(ClientTickEvents.EndTick { client ->
            KeybindingManager.onClientTick(client)
        })
        LOGGER.info("Client events have been registered.")
    }

}
