package net.shadowfacts.forgelin import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.fml.ExtensionPoint import net.minecraftforge.fml.config.ModConfig import java.util.function.Supplier object FMLKotlinModLoadingContext { private val context = ThreadLocal.withInitial { Context() } fun get(): Context { return context.get() } class Context { var activeContainer: FMLKotlinModContainer? = null val modEventBus: IEventBus get() = activeContainer!!.eventBus fun registerExtensionPoint(point: ExtensionPoint, extension: Supplier) { activeContainer!!.registerExtensionPoint(point, extension) } fun registerConfig(type: ModConfig.Type, spec: ForgeConfigSpec) { activeContainer!!.addConfig(ModConfig(type, spec, activeContainer!!)) } fun registerConfig(type: ModConfig.Type, spec: ForgeConfigSpec, fileName: String) { activeContainer!!.addConfig(ModConfig(type, spec, activeContainer, fileName)) } } }