diff --git a/fabric/src/main/kotlin/fr/username404/snowygui/fabric/FabricInit.kt b/fabric/src/main/kotlin/fr/username404/snowygui/fabric/FabricInit.kt index bd90afa..a61d956 100644 --- a/fabric/src/main/kotlin/fr/username404/snowygui/fabric/FabricInit.kt +++ b/fabric/src/main/kotlin/fr/username404/snowygui/fabric/FabricInit.kt @@ -8,7 +8,7 @@ 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 net.fabricmc.loader.api.FabricLoader -import java.net.URLClassLoader +import net.fabricmc.loader.launch.common.FabricLauncherBase import kotlin.io.path.exists import kotlin.io.path.isDirectory import kotlin.io.path.listDirectoryEntries @@ -28,12 +28,11 @@ class FabricInit: Snowy(), ClientModInitializer { val modsPaths = FabricLoader.getInstance().allMods.map { it.getPath(FeaturePackage.replace('.', '/')) }.filter { it.exists() && it.isDirectory() } - val buttonsLoader = URLClassLoader(modsPaths.map { it.toUri().toURL() }.toTypedArray(), Thread.currentThread().contextClassLoader) annotatedButtons = modsPaths.flatMap { buttonsDirectory -> val classSet = mutableSetOf>() buttonsDirectory.run { listDirectoryEntries("*.class").forEach { file -> - val foundClass = buttonsLoader.loadClass(file.pathString.drop(1).replace('/', '.').removeSuffix(".class")) + val foundClass = FabricLauncherBase.getClass(file.pathString.drop(1).replace('/', '.').removeSuffix(".class")) if (foundClass.isValidForButtonCollection()) classSet.add(foundClass.asSubclass(ButtonImpl::class.java)) } }