Update Forge version to build 191

This commit is contained in:
autaut03 2019-02-14 21:11:18 +02:00
parent 133bc4a46f
commit 74982308b1
4 changed files with 22 additions and 39 deletions

View File

@ -10,7 +10,7 @@ archivesBaseName = Forgelin
mc_version = 1.12.2
mappings_channel = snapshot
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
annotations_version = 17.0.0

View File

@ -4,14 +4,17 @@ import net.minecraftforge.eventbus.EventBusErrorMessage
import net.minecraftforge.eventbus.api.Event
import net.minecraftforge.eventbus.api.IEventBus
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.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.ModFileScanData
import org.apache.logging.log4j.LogManager
import java.util.*
import java.util.function.Consumer
import java.util.function.Supplier
class FMLKotlinModContainer(
info: IModInfo,
@ -36,7 +39,10 @@ class FMLKotlinModContainer(
triggerMap[ModLoadingStage.PROCESS_IMC] = dummy().andThen(::beforeEvent).andThen(::fireEvent).andThen(::afterEvent)
triggerMap[ModLoadingStage.COMPLETE] = dummy().andThen(::beforeEvent).andThen(::fireEvent).andThen(::afterEvent)
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 {
// 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 beforeEvent(lifecycleEvent: LifecycleEventProvider.LifecycleEvent) {
FMLKotlinModLoadingContext.get().activeContainer = this
ModThreadContext.get().activeContainer = this
}
private fun beforeEvent(lifecycleEvent: LifecycleEventProvider.LifecycleEvent) {}
private fun fireEvent(lifecycleEvent: LifecycleEventProvider.LifecycleEvent) {
val event = lifecycleEvent.getOrBuildEvent(this)
@ -89,8 +92,6 @@ class FMLKotlinModContainer(
}
private fun afterEvent(lifecycleEvent: LifecycleEventProvider.LifecycleEvent) {
ModThreadContext.get().activeContainer = null
FMLKotlinModLoadingContext.get().activeContainer = null
if (currentState == ModLoadingStage.ERROR) {
logger.error(LOADING, "An error occurred while dispatching event {} to {}", lifecycleEvent.fromStage(), getModId())
}

View File

@ -1,34 +1,15 @@
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
import net.minecraftforge.fml.ModLoadingContext
object FMLKotlinModLoadingContext {
private val context = ThreadLocal.withInitial { Context() }
fun get(): Context {
return context.get()
return ModLoadingContext.get().extension()
}
class Context {
var activeContainer: FMLKotlinModContainer? = null
class Context(private val container: FMLKotlinModContainer) {
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!!))
}
fun registerConfig(type: ModConfig.Type, spec: ForgeConfigSpec, fileName: String) {
activeContainer!!.addConfig(ModConfig(type, spec, activeContainer, fileName))
}
get() = container.eventBus
}
}

View File

@ -5,20 +5,21 @@ import net.minecraftforge.forgespi.language.IModInfo
import net.minecraftforge.forgespi.language.IModLanguageProvider
import net.minecraftforge.forgespi.language.ModFileScanData
import org.apache.logging.log4j.LogManager
import java.lang.Exception
class FMLKotlinModTarget(private val className: String, val modId: String) : IModLanguageProvider.IModLanguageLoader {
private val logger = LogManager.getLogger()
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 {
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)
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)
return constructor.newInstance(info, className, modClassLoader, modFileScanResults) as T
} catch (e: ReflectiveOperationException) {
return constructor.newInstance(info, className, modClassLoader, modFileScanResults) as T*/
} catch (e: Exception) {
logger.fatal(LOADING, "Unable to load FMLKotlinModContainer, wut?", e)
throw e
}