Don't use URLClassLoader instances on fabric
This commit is contained in:
parent
3290db57a9
commit
7c9e98bdc0
|
@ -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<Class<out ButtonImpl>>()
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue