Skip to content

Commit

Permalink
Do not use isolated-lwjgl3-loader on 1.16+
Browse files Browse the repository at this point in the history
  • Loading branch information
Deftu committed Jan 29, 2025
1 parent b2d18dd commit d38fccc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
10 changes: 10 additions & 0 deletions buildSrc/src/main/kotlin/org/polyfrost/gradle/addDependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ fun Project.provideIncludedDependencies(version: Triple<Int, Int, Int>?, loader:
}

deps.add(libs.findLibrary("copycat-image-awt").get().get())

if (version != null && version.second >= 16) {
// Modern (1.16+)
val lwjglBase = "org.lwjgl:lwjgl"
val lwjglVersion = if (version.second in 16..17) "3.2.2" else "3.3.2"

deps.add("$lwjglBase-tinyfd:$lwjglVersion")
deps.add("$lwjglBase-nanovg:$lwjglVersion")
}

deps.add(libs.findLibrary("polyui").get().get())
deps.add(libs.findLibrary("hypixel-modapi").get().get())
deps.add(libs.findLibrary("hypixel-data").get().get())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,19 @@

//#if MC >= 1.16.5
//$$ import org.lwjgl.opengl.GL;
//$$ import org.polyfrost.oneconfig.api.platform.v1.Platform;
//$$ import org.polyfrost.lwjgl.isolatedloader.Lwjgl3Downloader;
//$$ import java.nio.file.Path;
//#else
import org.lwjgl.opengl.GLContext;
import org.polyfrost.lwjgl.isolatedloader.Lwjgl3Manager;
import org.polyfrost.lwjgl.isolatedloader.classloader.IsolatedClassLoader;
//#endif

import net.minecraft.client.Minecraft;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.polyfrost.lwjgl.isolatedloader.Lwjgl3Manager;
import org.polyfrost.lwjgl.isolatedloader.classloader.IsolatedClassLoader;
import org.polyfrost.oneconfig.api.ClassHasOverwrites;
import org.polyfrost.oneconfig.api.ui.v1.api.LwjglApi;
import org.polyfrost.oneconfig.api.ui.v1.api.NanoVgApi;
Expand Down Expand Up @@ -82,12 +85,21 @@ public UIManagerImpl() throws Throwable {
//$$ System.setProperty("isolatedlwjgl3loader.earlyVersion3", "true");
//#endif

Lwjgl3Manager.initialize(getClass().getClassLoader(), new String[] { "nanovg", "stb", "tinyfd" });
String[] lwjglModules = new String[]{"nanovg", "stb", "tinyfd"};

//#if MC >= 1.16.5
//$$ Set<Path> nativesPaths = Lwjgl3Downloader.downloadNatives(lwjglModules);
//$$ for (Path path : nativesPaths) {
//$$ Platform.loader().addToClasspath(path);
//$$ }
//#else
Lwjgl3Manager.initialize(getClass().getClassLoader(), lwjglModules);

IsolatedClassLoader classLoader = Lwjgl3Manager.getClassLoader();

classLoader.addLoadingException("kotlin.");
classLoader.addLoadingException("org.polyfrost.oneconfig.api.ui.v1.api.");
//#endif

try {
boolean gl3 =
Expand All @@ -97,10 +109,17 @@ public UIManagerImpl() throws Throwable {
GLContext.getCapabilities().OpenGL30;
//#endif

//#if MC >= 1.16.5
//$$ lwjgl = new LwjglImpl();
//$$ nanoVg = new NanoVgImpl(gl3);
//$$ stb = new StbImpl();
//$$ tinyFD = new TinyFdImpl();
//#else
lwjgl = Lwjgl3Manager.getIsolated(LwjglApi.class, LWJGL_IMPL_PACKAGE + "LwjglImpl");
nanoVg = Lwjgl3Manager.getIsolated(NanoVgApi.class, LWJGL_IMPL_PACKAGE + "NanoVgImpl", gl3);
stb = Lwjgl3Manager.getIsolated(StbApi.class, LWJGL_IMPL_PACKAGE + "StbImpl");
tinyFD = Lwjgl3Manager.getIsolated(TinyFdApi.class, LWJGL_IMPL_PACKAGE + "TinyFdImpl");
//#endif

renderer = new RendererImpl(gl3, lwjgl, nanoVg, stb);
} catch (Exception e) {
Expand Down

0 comments on commit d38fccc

Please sign in to comment.