package tech.thatgravyboat.rewardclaim.adapter import net.minecraftforge.fml.common.FMLModContainer import net.minecraftforge.fml.common.ILanguageAdapter import net.minecraftforge.fml.common.ModContainer import net.minecraftforge.fml.relauncher.Side import java.lang.reflect.Field import java.lang.reflect.Method class KotlinLanguageAdapter : ILanguageAdapter { override fun supportsStatics() = false override fun setProxy(target: Field, proxyTarget: Class<*>, proxy: Any) { target.set(proxyTarget.getDeclaredField("INSTANCE").get(null), proxy) } override fun getNewInstance( container: FMLModContainer, objectClass: Class<*>, classLoader: ClassLoader, factoryMarkedAnnotation: Method? ): Any { return objectClass.fields.find { it.name == "INSTANCE" }?.get(null) ?: objectClass.newInstance() } override fun setInternalProxies(mod: ModContainer?, side: Side?, loader: ClassLoader?) {} }