Use forge events in forgeInit.kt, and add a @JvmStatic annotation to the logger in Snowy.kt

This commit is contained in:
Username404-59 2021-04-09 15:20:08 +02:00
parent 3b55558ca4
commit 6bb1e6eac8
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
2 changed files with 12 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import org.apache.logging.log4j.Logger
abstract class Snowy {
companion object {
@JvmStatic
val logs: Logger = LogManager.getLogger("Snowy")
}
fun atInit() {

View File

@ -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)
}
}
}