From 2e2583a1f1964714624744c342321602d41b3eae Mon Sep 17 00:00:00 2001 From: inglettronald Date: Thu, 8 Jun 2023 19:56:59 -0500 Subject: houseKeeping --- src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt | 21 ++++++--------------- src/main/kotlin/com/dulkirfabric/Registrations.kt | 18 +++++++++++++++--- 2 files changed, 21 insertions(+), 18 deletions(-) (limited to 'src/main/kotlin/com/dulkirfabric') diff --git a/src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt b/src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt index 0a66f69..ca8a21c 100644 --- a/src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt +++ b/src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt @@ -13,13 +13,12 @@ package com.dulkirfabric +import com.dulkirfabric.config.DulkirConfig import com.dulkirfabric.events.WidgetInitEvent import meteordevelopment.orbit.EventBus import meteordevelopment.orbit.EventHandler import net.fabricmc.api.ModInitializer -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents import net.minecraft.client.MinecraftClient -import net.minecraft.client.gui.screen.Screen import org.slf4j.LoggerFactory import java.lang.invoke.MethodHandles @@ -31,27 +30,23 @@ object DulkirModFabric : ModInitializer { @JvmField val mc: MinecraftClient = MinecraftClient.getInstance() var widgetLoadTime = 0L - var delayedScreen: Screen? = null override fun onInitialize() { logger.info("Initializing DulkirMod...") + + // Orbit stuff EVENT_BUS.registerLambdaFactory("com.dulkirfabric") { lookupInMethod, klass -> lookupInMethod.invoke(null, klass, MethodHandles.lookup()) as MethodHandles.Lookup } - // Register a tick event listener to delay the screen opening - ClientTickEvents.END_CLIENT_TICK.register(ClientTickEvents.EndTick { client: MinecraftClient? -> - if (delayedScreen != null) { - MinecraftClient.getInstance().setScreen(delayedScreen) - delayedScreen = null - } - }) - Registrations.registerEventListeners() Registrations.registerCommands() + + DulkirConfig.loadConfig() } + @EventHandler fun onPreInit(event: WidgetInitEvent) { if (!event.initialized) println("have not initialized widgets yet!!!!") @@ -64,8 +59,4 @@ object DulkirModFabric : ModInitializer { if (event.initialized) println("widgets initialized!!!!!, took: $time ns") } - // Call this method when you want to open the new screen - fun openScreenDelayed(screen: Screen) { - delayedScreen = screen - } } \ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/Registrations.kt b/src/main/kotlin/com/dulkirfabric/Registrations.kt index 101feca..3068b86 100644 --- a/src/main/kotlin/com/dulkirfabric/Registrations.kt +++ b/src/main/kotlin/com/dulkirfabric/Registrations.kt @@ -2,10 +2,8 @@ package com.dulkirfabric import com.dulkirfabric.DulkirModFabric.EVENT_BUS import com.dulkirfabric.commands.ConfigCommand -import com.mojang.brigadier.CommandDispatcher +import com.dulkirfabric.commands.JoinDungeonCommands import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource -import net.minecraft.command.CommandRegistryAccess /** * Collection of different mod registration stuff ran on initializing the mod. It is separated for readability @@ -16,6 +14,20 @@ object Registrations { fun registerCommands() { val cre = ClientCommandRegistrationCallback.EVENT cre.register(ConfigCommand::register) + cre.register(JoinDungeonCommands.F1Command::register) + cre.register(JoinDungeonCommands.F2Command::register) + cre.register(JoinDungeonCommands.F3Command::register) + cre.register(JoinDungeonCommands.F4Command::register) + cre.register(JoinDungeonCommands.F5Command::register) + cre.register(JoinDungeonCommands.F6Command::register) + cre.register(JoinDungeonCommands.F7Command::register) + cre.register(JoinDungeonCommands.M1Command::register) + cre.register(JoinDungeonCommands.M2Command::register) + cre.register(JoinDungeonCommands.M3Command::register) + cre.register(JoinDungeonCommands.M4Command::register) + cre.register(JoinDungeonCommands.M5Command::register) + cre.register(JoinDungeonCommands.M6Command::register) + cre.register(JoinDungeonCommands.M7Command::register) } fun registerEventListeners() { -- cgit