Kotlin for Forge

Kotlin for Forge

70M Downloads

AutoKotlinEventBusSubscriber attempts to load companion objects on invalid sides

chylex opened this issue ยท 1 comments

commented
val ktObject = Class.forName(annotationData.classType.className, true, classLoader).kotlin.objectInstance

if (ktObject != null && mod.modId == modid && DIST in sides) {

This loads the object instance before checking whether it even makes sense on the current side, causing a crash if the companion object uses side-only classes. For instance,

class TestModel private constructor(sourceModel: IBakedModel) : BakedModelWrapper<IBakedModel>(sourceModel){
	@EventBusSubscriber(Dist.CLIENT, modid = "mod", bus = MOD)
	companion object{
		private lateinit var modelRegistry: MutableMap<ResourceLocation, IBakedModel>
	}
}

crashes on a dedicated server with

[modloading-worker-0/FATAL] [ne.mi.fm.lo.RuntimeDistCleaner/DISTXFORM]: Attempted to load class net/minecraft/client/renderer/model/IBakedModel for invalid dist DEDICATED_SERVER
commented

Ah I see. I'll do the sides check earlier