Skip to content

Commit

Permalink
support run17
Browse files Browse the repository at this point in the history
  • Loading branch information
Windmill-City committed Jan 13, 2024
1 parent cba17dd commit c2a7ab5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions 1.7.10/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ tasks {
attributes(getManifestAttributes())
}
configurations = listOf(shadowCompileOnly)
minimize()
}
reobfJar {
inputJar.set(shadowJar.flatMap { it.archiveFile })
Expand Down
16 changes: 15 additions & 1 deletion 1.7.10/src/main/java/city/windmill/ingameime/Internal.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,25 @@ private static void tryLoadLibrary(String libName) {
LIBRARY_LOADED = true;
LOG.info("Library [{}] has loaded!", libName);
} catch (Throwable e) {
LOG.warn("Try to load library [{}] but failed", libName, e);
LOG.warn("Try to load library [{}] but failed: {}", libName, e.getClass().getSimpleName());
}
else
LOG.info("Library has loaded, skip loading of [{}]", libName);
}

private static long getWindowHandle_LWJGL3() {
try {
Method getWindow = Display.class.getMethod("getWindow");
Class<?> NativeWin32 = Class.forName("org.lwjgl.glfw.GLFWNativeWin32");
long glfwWindow = (long) getWindow.invoke(null);
Method glfwGetWin32Window = NativeWin32.getMethod("glfwGetWin32Window", long.class);
return (long) glfwGetWin32Window.invoke(null, glfwWindow);
} catch (Throwable e) {
LOG.error("Failed to get window handle", e);
return 0;
}
}

private static long getWindowHandle_LWJGL2() {
//long org.lwjgl.opengl.WindowsDisplay.getHwnd()
try {
Expand Down Expand Up @@ -80,6 +93,7 @@ public static void createInputCtx() {
LOG.info("Using IngameIME-Native: {}", InputContext.getVersion());

long hWnd = getWindowHandle_LWJGL2();
if (hWnd == 0) hWnd = getWindowHandle_LWJGL3();
if (hWnd != 0) {
// Once switched to the full screen, we can't back to not UiLess mode, unless restart the game
if (Minecraft.getMinecraft().isFullScreen())
Expand Down

0 comments on commit c2a7ab5

Please sign in to comment.