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 {
|
2019-02-12 22:09:24 +00:00
|
|
|
private val context = ThreadLocal.withInitial { Context() }
|
2019-02-12 19:20:49 +00:00
|
|
|
|
2019-02-12 22:09:24 +00:00
|
|
|
fun get(): Context {
|
2019-02-12 19:20:49 +00:00
|
|
|
return context.get()
|
|
|
|
}
|
|
|
|
|
2019-02-12 22:09:24 +00:00
|
|
|
class Context {
|
|
|
|
var activeContainer: FMLKotlinModContainer? = null
|
2019-02-12 19:20:49 +00:00
|
|
|
|
2019-02-12 22:09:24 +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
|
|
|
|
2019-02-12 22:09:24 +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
|
|
|
}
|
|
|
|
}
|