mirror of
https://codeberg.org/moonleay/Gimbal.git
synced 2025-04-19 06:54:44 +02:00
57 lines
2.3 KiB
Kotlin
57 lines
2.3 KiB
Kotlin
/*
|
|
* Gimbal
|
|
* Copyright (C) 2024 moonleay
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package net.moonleay.gimbal.client
|
|
|
|
import net.fabricmc.api.ClientModInitializer
|
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
|
|
import net.fabricmc.fabric.api.client.networking.v1.ClientLoginConnectionEvents
|
|
import net.moonleay.gimbal.build.BuildConstants
|
|
import net.moonleay.gimbal.client.editor.ClientEditor
|
|
import net.moonleay.gimbal.client.keybindings.KeybindingManager
|
|
import net.moonleay.gimbal.client.keybindings.KeybindingRegistrar
|
|
import net.moonleay.gimbal.networking.GimbalClient
|
|
import org.apache.logging.log4j.LogManager
|
|
|
|
internal object ClientMain : ClientModInitializer {
|
|
private val LOGGER = LogManager.getLogger(BuildConstants.modName)
|
|
|
|
|
|
override fun onInitializeClient() {
|
|
LOGGER.info("Initializing Gimbal on the client side...")
|
|
KeybindingRegistrar.registerKeybindings()
|
|
this.registerEvents()
|
|
LOGGER.info("Registering packets...")
|
|
GimbalClient.registerPacketHandlers()
|
|
LOGGER.info("Packets have been registered.")
|
|
LOGGER.info("Gimbal 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)
|
|
})
|
|
|
|
ClientLoginConnectionEvents.INIT.register(ClientLoginConnectionEvents.Init { _, _ ->
|
|
ClientEditor.onConnectedToNewWorld() // Client is connecting to a new server, reset the editor
|
|
})
|
|
LOGGER.info("Client events have been registered.")
|
|
}
|
|
|
|
}
|