From 6bb1e6eac8d1aab41fdd70a8f1529b37e708ad57 Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Fri, 9 Apr 2021 15:20:08 +0200 Subject: [PATCH] Use forge events in forgeInit.kt, and add a @JvmStatic annotation to the logger in Snowy.kt --- .../main/kotlin/fr/username404/snowygui/Snowy.kt | 1 + .../fr/username404/snowygui/forge/forgeInit.kt | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/common/src/main/kotlin/fr/username404/snowygui/Snowy.kt b/common/src/main/kotlin/fr/username404/snowygui/Snowy.kt index 6d87943..96f16c3 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/Snowy.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/Snowy.kt @@ -5,6 +5,7 @@ import org.apache.logging.log4j.Logger abstract class Snowy { companion object { + @JvmStatic val logs: Logger = LogManager.getLogger("Snowy") } fun atInit() { diff --git a/forge/src/main/kotlin/fr/username404/snowygui/forge/forgeInit.kt b/forge/src/main/kotlin/fr/username404/snowygui/forge/forgeInit.kt index c106fd3..f39f206 100644 --- a/forge/src/main/kotlin/fr/username404/snowygui/forge/forgeInit.kt +++ b/forge/src/main/kotlin/fr/username404/snowygui/forge/forgeInit.kt @@ -5,13 +5,16 @@ import fr.username404.snowygui.config.SnowyConfigScreen import net.minecraftforge.fml.ExtensionPoint import net.minecraftforge.fml.ModLoadingContext import net.minecraftforge.fml.common.Mod +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent +import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext import java.util.function.BiFunction import java.util.function.Supplier @Mod("snowygui") class ForgeInit: Snowy() { - init { - atInit() + private fun initSetup(event: FMLCommonSetupEvent) = atInit() + private fun configSetup(event: FMLClientSetupEvent) { ModLoadingContext.get().registerExtensionPoint( ExtensionPoint.CONFIGGUIFACTORY, Supplier { @@ -23,4 +26,10 @@ class ForgeInit: Snowy() { } ) } + init { + with(FMLJavaModLoadingContext.get().modEventBus) { + addListener(this@ForgeInit::initSetup) + addListener(this@ForgeInit::configSetup) + } + } } \ No newline at end of file