Forgelin/src/main/kotlin/net/shadowfacts/forgelin/FMLKotlinModLoadingContext.kt

34 lines
1.1 KiB
Kotlin
Raw Normal View History

2019-02-12 19:20:49 +00:00
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() }
2019-02-12 19:20:49 +00:00
fun get(): Context {
2019-02-12 19:20:49 +00:00
return context.get()
}
class Context {
var activeContainer: FMLKotlinModContainer? = null
2019-02-12 19:20:49 +00:00
val modEventBus: IEventBus
get() = activeContainer!!.eventBus
fun <T> registerExtensionPoint(point: ExtensionPoint<T>, extension: Supplier<T>) {
activeContainer!!.registerExtensionPoint(point, extension)
}
fun registerConfig(type: ModConfig.Type, spec: ForgeConfigSpec) {
activeContainer!!.addConfig(ModConfig(type, spec, activeContainer!!))
}
2019-02-12 19:20:49 +00:00
fun registerConfig(type: ModConfig.Type, spec: ForgeConfigSpec, fileName: String) {
activeContainer!!.addConfig(ModConfig(type, spec, activeContainer, fileName))
}
2019-02-12 19:20:49 +00:00
}
}