Fix the ButtonImpl.initialize() method producing null, use reflections8 only on fabric and shadow kotlinx.serialization on forge
This commit is contained in:
parent
c39670c764
commit
f9fd9222ef
|
@ -87,8 +87,7 @@ subprojects {
|
|||
listOf(
|
||||
"$kotlinX:kotlinx-datetime:0.2.0",
|
||||
"com.typesafe:config:1.4.1",
|
||||
"io.github.config4k:config4k:0.4.2",
|
||||
"net.oneandone.reflections8:reflections8:0.11.7", "org.javassist:javassist:3.28.0-GA"
|
||||
"io.github.config4k:config4k:0.4.2"
|
||||
).forEach { implementation(it); shadowC(it) { isTransitive = false; } }
|
||||
"minecraft"("com.mojang:minecraft:${rootProject.property("minecraft")}")
|
||||
"mappings"(mappingsDep)
|
||||
|
@ -126,7 +125,8 @@ allprojects {
|
|||
}
|
||||
tasks {
|
||||
withType(ShadowJar::class) {
|
||||
relocate("kotlinx-datetime", "${rootProject.group}.kotlinx-datetime")
|
||||
relocate("kotlinx.datetime", "${rootProject.group}.datetime")
|
||||
relocate("kotlinx.serialization", "${rootProject.group}.serialization")
|
||||
relocate("org.jetbrains", "${rootProject.group}.jetbrainslibs")
|
||||
relocate("javassist", "${rootProject.group}.javassist")
|
||||
relocate("org.reflections8", "${rootProject.group}.reflectionlib")
|
||||
|
|
|
@ -2,25 +2,15 @@ package fr.username404.snowygui
|
|||
|
||||
import fr.username404.snowygui.EventSnowy.Companion.useKey
|
||||
import fr.username404.snowygui.config.Configuration.obtained
|
||||
import fr.username404.snowygui.gui.feature.ButtonInfo
|
||||
import fr.username404.snowygui.misc.AddKeyMaps
|
||||
import io.github.config4k.getValue
|
||||
import org.apache.logging.log4j.LogManager
|
||||
import org.apache.logging.log4j.Logger
|
||||
import org.reflections8.Reflections
|
||||
import org.reflections8.scanners.SubTypesScanner
|
||||
import org.reflections8.scanners.TypeAnnotationsScanner
|
||||
import org.reflections8.util.ClasspathHelper
|
||||
import org.reflections8.util.ConfigurationBuilder
|
||||
|
||||
abstract class Snowy {
|
||||
private val displayInitMessage: Boolean by obtained
|
||||
companion object {
|
||||
var annotatedButtons: Set<Class<*>> = Reflections(ConfigurationBuilder()
|
||||
.setUrls(ClasspathHelper.forClassLoader())
|
||||
.setScanners(SubTypesScanner(false), TypeAnnotationsScanner())
|
||||
.useParallelExecutor()
|
||||
).getTypesAnnotatedWith(ButtonInfo::class.java)
|
||||
lateinit var annotatedButtons: Set<Class<*>>
|
||||
fun onEvent(e: String, lambda: argsLambda) = useKey(e).add(lambda)
|
||||
@JvmField
|
||||
val logs: Logger = LogManager.getLogger()
|
||||
|
|
|
@ -11,6 +11,7 @@ import fr.username404.snowygui.gui.Renderable.Rendering.defaultRectFunc
|
|||
import fr.username404.snowygui.gui.elements.ClickBox
|
||||
import fr.username404.snowygui.gui.feature.ButtonInfo.Companion.Type
|
||||
import kotlin.reflect.full.findAnnotation
|
||||
import kotlin.reflect.jvm.isAccessible
|
||||
|
||||
abstract class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
||||
companion object {
|
||||
|
@ -21,7 +22,9 @@ abstract class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
|||
((try {
|
||||
it.getConstructor().newInstance()
|
||||
} catch (e: NoSuchMethodException) {
|
||||
it.kotlin.objectInstance
|
||||
try {
|
||||
it.kotlin.objectInstance!!
|
||||
} catch (e: NullPointerException) { it.kotlin.constructors.first().also { build -> build.isAccessible = true }.call() }
|
||||
}) as ButtonImpl).let { impl ->
|
||||
with(impl) {
|
||||
if (info.kind == ButtonInfo.Companion.Type.TOGGLE) {
|
||||
|
|
|
@ -18,6 +18,7 @@ dependencies {
|
|||
include(modApi("${Groups.FabricApi}:fabric-api-base:${rootProject.property("fabric_api_base_version")}")!!)
|
||||
include(modRuntime("${Groups.FabricApi}:fabric-resource-loader-v0:${rootProject.property("fabric_resource_loader_version")}")!!)
|
||||
modImplementation(group = "net.fabricmc", name = "fabric-language-kotlin", version = rootProject.property("fabric_language_kotlin") as String)
|
||||
listOf("net.oneandone.reflections8:reflections8:0.11.7", "org.javassist:javassist:3.28.0-GA").forEach { implementation(it); shadowC(it) { isTransitive = false } }
|
||||
modRuntime(modCompileOnly("com.terraformersmc:modmenu:${rootProject.property("modmenu_version")}") {
|
||||
exclude(group = Groups.FabricApi, module = "fabric-api-base")
|
||||
exclude(group = Groups.FabricApi, module = "fabric-resource-loader-v0")
|
||||
|
|
|
@ -3,9 +3,15 @@ package fr.username404.snowygui.fabric
|
|||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import fr.username404.snowygui.EventSnowy
|
||||
import fr.username404.snowygui.Snowy
|
||||
import fr.username404.snowygui.gui.feature.ButtonInfo
|
||||
import net.fabricmc.api.ClientModInitializer
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback.EVENT
|
||||
import org.reflections8.Reflections
|
||||
import org.reflections8.scanners.SubTypesScanner
|
||||
import org.reflections8.scanners.TypeAnnotationsScanner
|
||||
import org.reflections8.util.ClasspathHelper
|
||||
import org.reflections8.util.ConfigurationBuilder
|
||||
|
||||
class FabricInit: Snowy(), ClientModInitializer {
|
||||
override fun onInitializeClient() {
|
||||
|
@ -17,4 +23,12 @@ class FabricInit: Snowy(), ClientModInitializer {
|
|||
}
|
||||
)
|
||||
}
|
||||
init {
|
||||
annotatedButtons = Reflections(
|
||||
ConfigurationBuilder()
|
||||
.setUrls(ClasspathHelper.forClassLoader())
|
||||
.setScanners(SubTypesScanner(false), TypeAnnotationsScanner())
|
||||
.useParallelExecutor()
|
||||
).getTypesAnnotatedWith(ButtonInfo::class.java)
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ dependencies {
|
|||
implementation("thedarkcolour:kotlinforforge:${rootProject.property("kotlinforforge")}.0")
|
||||
implementation(project(path = ":common")) { isTransitive = false }
|
||||
add("developmentForge", project(path = ":common")) { isTransitive = false }
|
||||
shadowC("org.jetbrains.kotlinx:kotlinx-serialization-core:1.2.1") { isTransitive = false }
|
||||
shadowC(project(path = ":common", configuration = "transformProductionForge")) { isTransitive = false }
|
||||
}; loom {
|
||||
useFabricMixin = true
|
||||
|
|
Loading…
Reference in New Issue