Update Forge version to build 191
This commit is contained in:
parent
133bc4a46f
commit
74982308b1
|
@ -10,7 +10,7 @@ archivesBaseName = Forgelin
|
||||||
mc_version = 1.12.2
|
mc_version = 1.12.2
|
||||||
mappings_channel = snapshot
|
mappings_channel = snapshot
|
||||||
mappings_version = 20180921-1.13
|
mappings_version = 20180921-1.13
|
||||||
forge_version = net.minecraftforge.test:forge:1.13-24.0.183-1.13-pre
|
forge_version = net.minecraftforge.test:forge:1.13-24.0.191-1.13-pre
|
||||||
|
|
||||||
kotlin_version = 1.3.21
|
kotlin_version = 1.3.21
|
||||||
annotations_version = 17.0.0
|
annotations_version = 17.0.0
|
||||||
|
|
|
@ -4,14 +4,17 @@ import net.minecraftforge.eventbus.EventBusErrorMessage
|
||||||
import net.minecraftforge.eventbus.api.Event
|
import net.minecraftforge.eventbus.api.Event
|
||||||
import net.minecraftforge.eventbus.api.IEventBus
|
import net.minecraftforge.eventbus.api.IEventBus
|
||||||
import net.minecraftforge.eventbus.api.IEventListener
|
import net.minecraftforge.eventbus.api.IEventListener
|
||||||
import net.minecraftforge.fml.*
|
import net.minecraftforge.fml.LifecycleEventProvider
|
||||||
import net.minecraftforge.fml.Logging.LOADING
|
import net.minecraftforge.fml.Logging.LOADING
|
||||||
import net.minecraftforge.fml.config.ModConfig
|
import net.minecraftforge.fml.ModContainer
|
||||||
|
import net.minecraftforge.fml.ModLoadingException
|
||||||
|
import net.minecraftforge.fml.ModLoadingStage
|
||||||
import net.minecraftforge.forgespi.language.IModInfo
|
import net.minecraftforge.forgespi.language.IModInfo
|
||||||
import net.minecraftforge.forgespi.language.ModFileScanData
|
import net.minecraftforge.forgespi.language.ModFileScanData
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.function.Consumer
|
import java.util.function.Consumer
|
||||||
|
import java.util.function.Supplier
|
||||||
|
|
||||||
class FMLKotlinModContainer(
|
class FMLKotlinModContainer(
|
||||||
info: IModInfo,
|
info: IModInfo,
|
||||||
|
@ -36,7 +39,10 @@ class FMLKotlinModContainer(
|
||||||
triggerMap[ModLoadingStage.PROCESS_IMC] = dummy().andThen(::beforeEvent).andThen(::fireEvent).andThen(::afterEvent)
|
triggerMap[ModLoadingStage.PROCESS_IMC] = dummy().andThen(::beforeEvent).andThen(::fireEvent).andThen(::afterEvent)
|
||||||
triggerMap[ModLoadingStage.COMPLETE] = dummy().andThen(::beforeEvent).andThen(::fireEvent).andThen(::afterEvent)
|
triggerMap[ModLoadingStage.COMPLETE] = dummy().andThen(::beforeEvent).andThen(::fireEvent).andThen(::afterEvent)
|
||||||
eventBus = IEventBus.create(::onEventFailed)
|
eventBus = IEventBus.create(::onEventFailed)
|
||||||
configHandler = Optional.of<Consumer<ModConfig.ModConfigEvent>>(Consumer { event -> eventBus.post(event) })
|
configHandler = Optional.of(Consumer { event -> eventBus.post(event) })
|
||||||
|
|
||||||
|
val contextExtension = FMLKotlinModLoadingContext.Context(this)
|
||||||
|
this.contextExtension = Supplier { contextExtension }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Here, we won't init the class, meaning static {} blocks (init {} in kotlin) won't get triggered
|
// Here, we won't init the class, meaning static {} blocks (init {} in kotlin) won't get triggered
|
||||||
|
@ -70,10 +76,7 @@ class FMLKotlinModContainer(
|
||||||
|
|
||||||
private fun dummy(): Consumer<LifecycleEventProvider.LifecycleEvent> = Consumer {}
|
private fun dummy(): Consumer<LifecycleEventProvider.LifecycleEvent> = Consumer {}
|
||||||
|
|
||||||
private fun beforeEvent(lifecycleEvent: LifecycleEventProvider.LifecycleEvent) {
|
private fun beforeEvent(lifecycleEvent: LifecycleEventProvider.LifecycleEvent) {}
|
||||||
FMLKotlinModLoadingContext.get().activeContainer = this
|
|
||||||
ModThreadContext.get().activeContainer = this
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun fireEvent(lifecycleEvent: LifecycleEventProvider.LifecycleEvent) {
|
private fun fireEvent(lifecycleEvent: LifecycleEventProvider.LifecycleEvent) {
|
||||||
val event = lifecycleEvent.getOrBuildEvent(this)
|
val event = lifecycleEvent.getOrBuildEvent(this)
|
||||||
|
@ -89,8 +92,6 @@ class FMLKotlinModContainer(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun afterEvent(lifecycleEvent: LifecycleEventProvider.LifecycleEvent) {
|
private fun afterEvent(lifecycleEvent: LifecycleEventProvider.LifecycleEvent) {
|
||||||
ModThreadContext.get().activeContainer = null
|
|
||||||
FMLKotlinModLoadingContext.get().activeContainer = null
|
|
||||||
if (currentState == ModLoadingStage.ERROR) {
|
if (currentState == ModLoadingStage.ERROR) {
|
||||||
logger.error(LOADING, "An error occurred while dispatching event {} to {}", lifecycleEvent.fromStage(), getModId())
|
logger.error(LOADING, "An error occurred while dispatching event {} to {}", lifecycleEvent.fromStage(), getModId())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +1,15 @@
|
||||||
package net.shadowfacts.forgelin
|
package net.shadowfacts.forgelin
|
||||||
|
|
||||||
import net.minecraftforge.common.ForgeConfigSpec
|
|
||||||
import net.minecraftforge.eventbus.api.IEventBus
|
import net.minecraftforge.eventbus.api.IEventBus
|
||||||
import net.minecraftforge.fml.ExtensionPoint
|
import net.minecraftforge.fml.ModLoadingContext
|
||||||
import net.minecraftforge.fml.config.ModConfig
|
|
||||||
import java.util.function.Supplier
|
|
||||||
|
|
||||||
object FMLKotlinModLoadingContext {
|
object FMLKotlinModLoadingContext {
|
||||||
private val context = ThreadLocal.withInitial { Context() }
|
|
||||||
|
|
||||||
fun get(): Context {
|
fun get(): Context {
|
||||||
return context.get()
|
return ModLoadingContext.get().extension()
|
||||||
}
|
}
|
||||||
|
|
||||||
class Context {
|
class Context(private val container: FMLKotlinModContainer) {
|
||||||
var activeContainer: FMLKotlinModContainer? = null
|
|
||||||
|
|
||||||
val modEventBus: IEventBus
|
val modEventBus: IEventBus
|
||||||
get() = activeContainer!!.eventBus
|
get() = container.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!!))
|
|
||||||
}
|
|
||||||
|
|
||||||
fun registerConfig(type: ModConfig.Type, spec: ForgeConfigSpec, fileName: String) {
|
|
||||||
activeContainer!!.addConfig(ModConfig(type, spec, activeContainer, fileName))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,20 +5,21 @@ import net.minecraftforge.forgespi.language.IModInfo
|
||||||
import net.minecraftforge.forgespi.language.IModLanguageProvider
|
import net.minecraftforge.forgespi.language.IModLanguageProvider
|
||||||
import net.minecraftforge.forgespi.language.ModFileScanData
|
import net.minecraftforge.forgespi.language.ModFileScanData
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
|
import java.lang.Exception
|
||||||
|
|
||||||
class FMLKotlinModTarget(private val className: String, val modId: String) : IModLanguageProvider.IModLanguageLoader {
|
class FMLKotlinModTarget(private val className: String, val modId: String) : IModLanguageProvider.IModLanguageLoader {
|
||||||
private val logger = LogManager.getLogger()
|
private val logger = LogManager.getLogger()
|
||||||
|
|
||||||
override fun <T> loadMod(info: IModInfo, modClassLoader: ClassLoader, modFileScanResults: ModFileScanData): T {
|
override fun <T> loadMod(info: IModInfo, modClassLoader: ClassLoader, modFileScanResults: ModFileScanData): T {
|
||||||
// This language class is loaded in the system level classloader - before the game even starts
|
|
||||||
// So we must treat container construction as an arms length operation, and load the container
|
|
||||||
// in the classloader of the game - the context classloader is appropriate here.
|
|
||||||
try {
|
try {
|
||||||
|
return FMLKotlinModContainer(info, className, modClassLoader, modFileScanResults) as T
|
||||||
|
|
||||||
|
/*logger.debug(LOADING, "Loading FMLKotlinModContainer from classloader {}", Thread.currentThread().contextClassLoader)
|
||||||
val fmlContainer = Class.forName("net.shadowfacts.forgelin.FMLKotlinModContainer", true, Thread.currentThread().contextClassLoader)
|
val fmlContainer = Class.forName("net.shadowfacts.forgelin.FMLKotlinModContainer", true, Thread.currentThread().contextClassLoader)
|
||||||
logger.debug(LOADING, "Loading FMLKotlinModContainer from classloader {} - got {}", Thread.currentThread().contextClassLoader, fmlContainer.classLoader)
|
logger.debug(LOADING, "Loading FMLKotlinModContainer got {}", fmlContainer.classLoader)
|
||||||
val constructor = fmlContainer.getConstructor(IModInfo::class.java, String::class.java, ClassLoader::class.java, ModFileScanData::class.java)
|
val constructor = fmlContainer.getConstructor(IModInfo::class.java, String::class.java, ClassLoader::class.java, ModFileScanData::class.java)
|
||||||
return constructor.newInstance(info, className, modClassLoader, modFileScanResults) as T
|
return constructor.newInstance(info, className, modClassLoader, modFileScanResults) as T*/
|
||||||
} catch (e: ReflectiveOperationException) {
|
} catch (e: Exception) {
|
||||||
logger.fatal(LOADING, "Unable to load FMLKotlinModContainer, wut?", e)
|
logger.fatal(LOADING, "Unable to load FMLKotlinModContainer, wut?", e)
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue