Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minecraft example not working #99

Open
niklasbuesing opened this issue Jun 14, 2019 · 102 comments
Open

Minecraft example not working #99

niklasbuesing opened this issue Jun 14, 2019 · 102 comments

Comments

@niklasbuesing
Copy link

Hi!

I'm trying to use imgui in a Minecraft mod i'm making, so i started with the example in the wiki:

public class TestScreen extends Screen {

    private static ImGui imgui = ImGui.INSTANCE;

    private static ImplGL3 implGl3;
    private static ImplGlfw implGlfw;

    static {
        GlfwWindow window = GlfwWindow.from(MinecraftClient.getInstance().window.getHandle());
        window.makeContextCurrent();
        new Context();
        implGlfw = new ImplGlfw(window, false, null);
        implGl3 = new ImplGL3();
    }

    public TestScreen () {
        super(new TextComponent("Test Screen"));
    }

    @Override
    public void render(int x, int y, float partialTicks) {

        implGl3.newFrame(); // JVM crashes here
        implGlfw.newFrame();
        imgui.newFrame();

        imgui.text("Hello Minecraft!");

        implGl3.renderDrawData(imgui.getDrawData());

    }
}

Upon showing the screen however, the jvm crashes:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000006b2e0e20, pid=2940, tid=0x00000000000059f0
#
# JRE version: Java(TM) SE Runtime Environment (8.0_211-b12) (build 1.8.0_211-b12)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.211-b12 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [nvoglv64.dll+0xc20e20]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

hs_err_pid2940.log

I'm not sure why this happens, i'm using exactly the same code as in the wiki.

Any help would be appreciated!

@elect86
Copy link
Collaborator

elect86 commented Jun 14, 2019

I'll forward you to this guy (#96), who did the same

@zeroeightysix
Copy link
Collaborator

What does your build.gradle look like? You're crashing in native code, so I presume you're importing the wrong version(s) of LWJGL or the like. (Reference the answer in #96 if you need an example of what you need to add to your dependencies)

@niklasbuesing
Copy link
Author

I'm just using the default Fabric build.gradle, plus

repositories {
    ...
    maven { url = "https://jitpack.io" }
}

dependencies {
    ...
    
    ext{
        imguiVersion = "-SNAPSHOT"
    }
    ["gl", "glfw", "core"].each {
        implementation("com.github.kotlin-graphics.imgui:imgui-$it:$imguiVersion") {
            exclude group: "org.lwjgl"
        }
    }
}

I also tried the specific commit you used (fc9aad3), with the same result.

Dependencies seem okay

image

@niklasbuesing
Copy link
Author

niklasbuesing commented Jun 14, 2019

I tried it with several older fabric versions down to 1.14 trying to match your configuration, however it still crashes.

Anyways, i don't know what i've done, but now it crashes "gracefully":
(ImGui#getDrawData() just returns null)

java.lang.IllegalArgumentException: Parameter specified as non-null is null: method imgui.impl.ImplGL3.renderDrawData, parameter drawData
	at imgui.impl.ImplGL3.renderDrawData(ImplGL3.kt)
	at de.niklasb.client.TestScreen.render(TestScreen.java:42)
	at net.minecraft.client.gui.screen.SplashScreen.render(SplashScreen.java:56)
	at net.minecraft.client.render.GameRenderer.render(GameRenderer.java:534)
	at net.minecraft.client.MinecraftClient.render(MinecraftClient.java:896)
	at net.minecraft.client.MinecraftClient.start(MinecraftClient.java:386)
	at net.minecraft.client.main.Main.main(Main.java:126)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:170)
	at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:129)
	at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:26)

It's probably the same root cause, but i guess thats easier to debug.

I've made a minimal demo, maybe you can take a look at how it differs from your project.
It just shows the test screen immediately after minecraft initiliazed and then, at least for me, crashes.

fabric-example-mod.zip

@Sylvyrfysh
Copy link
Collaborator

Do you get any rendering at all? The code crashing inside the OpenGL natives leads me to believe that something is happening with the GL context in Minecraft that causes us to not have a proper GL context. This might be because you register your screen in the onInit method, at which point the window may not be properly initialized, causing us to clear all context when window.setContextCurrent() is called. I would try to add a key toggle that will only open it when you hit that key, which will delay initialization and make sure we grab the right window.

@niklasbuesing
Copy link
Author

niklasbuesing commented Jun 15, 2019

Tried that, but it unfortunately still crashes.

x

Sometimes because getDrawData() returns null (#99 (comment)), sometimes the jvm crashes (#99 (comment))

I've also tried calling ImGui#render before calling ImplGL3#renderDrawData, not sure if that's still required, just saw it in the tests, but that also didn't help.

@Sylvyrfysh
Copy link
Collaborator

Sylvyrfysh commented Jun 15, 2019

Give me the output of this, please?

TestScreen.kt

public class TestScreen extends Screen {

    private static ImGui imgui = ImGui.INSTANCE;

    private static ImplGL3 implGl3;
    private static ImplGlfw implGlfw;

    static {
        test();
        GlfwWindow window = GlfwWindow.from(MinecraftClient.getInstance().window.getHandle());
        window.makeContextCurrent();
        new Context();
        implGlfw = new ImplGlfw(window, false, null);
        implGl3 = new ImplGL3();
    }

    public static void test() {
        ImguiKt.setIMGUI_ENABLE_TEST_ENGINE(true);
        ImguiKt.setImGuiTestEngineHook_PreNewFrame(() -> {
            TestScreen.onNewFrame();
            return null;
        });
        ImguiKt.setImGuiTestEngineHook_PostNewFrame(() -> {
            TestScreen.onPostNewFrame();
            return null;
        });
        ImguiKt.setImGuiTestEngineHook_ItemAdd((rect, integer) -> {
            System.out.printf("Item added at %f %f sz %f %f\n", rect.getBl().getX(), rect.getBr().getY(), rect.getWidth(), rect.getHeight());
            return null;
        });
        ImguiKt.setImGuiTestEngineHook_ItemInfo((id, string, itm1) -> {
            System.out.printf("Item added id %d str %s int %d\n", id, string, itm1);
            return null;
        });
    }

    private static void onNewFrame() {
        System.out.println("Pre-NewFrame");
    }
    private static void onPostNewFrame() {
        System.out.println("Post-NewFrame");
    }

    public TestScreen () {
        super(new TextComponent("Test Screen"));
    }

    @Override
    public void render(int x, int y, float partialTicks) {

        implGl3.newFrame();
        implGlfw.newFrame();
        imgui.newFrame();

        imgui.text("Hello Minecraft!");
        
        imgui.render();

        implGl3.renderDrawData(imgui.getDrawData());

    }
}

@niklasbuesing
Copy link
Author

Sure

[06:19:59] [main/INFO]: [STDOUT]: Pre-NewFrame
Item added at 60.000000 73.000000 sz 13.000000 13.000000
Item added at 60.000000 79.000000 sz 400.000000 19.000000
[06:19:59] [main/INFO]: [STDOUT]: Post-NewFrame
[06:19:59] [main/INFO]: [STDOUT]: in (1.0, 1.0) (3.4028235E38, 3.4028235E38)
[LWJGL] [06:19:59] [main/INFO]: [STDERR]: Loading library: Imm32
[LWJGL] [06:19:59] [main/INFO]: [STDERR]: 	Imm32.dll not found in org.lwjgl.librarypath=C:\Users\User\AppData\Local\Temp\lwjglUser\3.2.1-build-12
[LWJGL] [06:19:59] [main/INFO]: [STDERR]: 	Loaded from system paths: C:\WINDOWS\System32\IMM32.DLL
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000000561328, pid=19924, tid=0x0000000000005dcc
#
# JRE version: Java(TM) SE Runtime Environment (8.0_211-b12) (build 1.8.0_211-b12)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.211-b12 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  0x0000000000561328
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\User\IdeaProjects\client\run\hs_err_pid19924.log
Compiled method (nm)   40450 6337     n 0       org.lwjgl.system.JNI::callPP (native)
 total in heap  [0x00000000047ae3d0,0x00000000047ae750] = 896
 relocation     [0x00000000047ae4f0,0x00000000047ae538] = 72
 main code      [0x00000000047ae540,0x00000000047ae748] = 520
 oops           [0x00000000047ae748,0x00000000047ae750] = 8
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

hs_err_pid19924.log

@Sylvyrfysh
Copy link
Collaborator

Sylvyrfysh commented Jun 15, 2019

Change the static block to this:

        test();
        GlfwWindow window = GlfwWindow.from(MinecraftClient.getInstance().window.getHandle());
        System.out.printf("GLFWWindow %d\n", MinecraftClient.getInstance().window.getHandle());
        window.makeContextCurrent();
        new Context();
        implGlfw = new ImplGlfw(window, false, null);
        implGl3 = new ImplGL3();

and does the GLFWWindow say it is 0?

My line of thinking on this issue is that all crashes we've seen here have a common root cause of a bad window. When we set the context as current on a dead/bad/non-existent window, we lose all GL functions, leading to a crash in uploading the font texture. It would also crash in the IME setposition.

Your null crash avoids this behavior by crashing before on window-specific code is called (besides font upload- the one hole with this theory), but this might be some GL client/server sync we're seeing that would generally only appear second frame or something.

If not, i'll try to get my modding environment working and see if it will work. Thank you for sticking with us through this!

@niklasbuesing
Copy link
Author

Window seems fine

GLFWWindow 569093408

Also not sure if relevant, but sometimes i have to run it a few times because it crashes before anything is printed with the original exception in my first comment

@Sylvyrfysh
Copy link
Collaborator

Even with the key toggle?

@niklasbuesing
Copy link
Author

Yep

@elect86
Copy link
Collaborator

elect86 commented Jun 15, 2019

I've made a minimal demo, maybe you can take a look at how it differs from your project.
It just shows the test screen immediately after minecraft initiliazed and then, at least for me, crashes.

fabric-example-mod.zip

How do you start that? I see no main

@niklasbuesing
Copy link
Author

First you have to run ./gradlew genSources, then depending on whether you use eclipse or intellij either ./gradlew eclipse or ./gradlew idea to generate the correct run configuration.

For other editors you can use those settings as reference:

image

Might help: https://fabricmc.net/wiki/tutorial:setup

@elect86
Copy link
Collaborator

elect86 commented Jun 15, 2019

weird

C:\Users\elect.gradle\caches\fabric-loom\minecraft-1.14.2-mapped-7.jar: The process cannot access the file because it is being used by another process.

@zeroeightysix
Copy link
Collaborator

I got it working with the zip you provided and a few changes:

I changed MinecraftClientMixin to MixinKeyboard and changed the mixin to this:

@Mixin(Keyboard.class)
public abstract class MixinKeyboard {

    @Inject(method = "onKey", at = @At(value = "HEAD"))
    public void onKey(long handle, int keycode, int scancode, int i3, int i4, CallbackInfo info) {
        if (MinecraftClient.getInstance().player != null && MinecraftClient.getInstance().currentScreen == null) {
            MinecraftClient.getInstance().openScreen(new TestScreen());
        }
    }

}

This way we can invoke imgui in-game by pressing a key (when we're sure everything of opengl/glfw etc has already been handled by minecraft)

And simply added imgui.render(); to your render method in TestScreen:

...
imgui.text("Hello Minecraft!");

imgui.render();

implGl3.renderDrawData(imgui.getDrawData());
...

I never ran into a JVM crash though. I'm on linux, so our natives are different.
Can you try the changes above and see if it works?

@niklasbuesing
Copy link
Author

Nope, still crashes :/

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000677a0e20, pid=6760, tid=0x000000000000396c
#
# JRE version: Java(TM) SE Runtime Environment (8.0_211-b12) (build 1.8.0_211-b12)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.211-b12 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [nvoglv64.dll+0xc20e20]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\User\Desktop\fabric-example-mod\run\hs_err_pid6760.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

hs_err_pid6760.log

@elect86
Copy link
Collaborator

elect86 commented Jun 15, 2019

Solved the NPE, it was because there was a missing imgui.render(); before implGl3.renderDrawData(imgui.getDrawData()); zeroeightysix already got that

Now I get the jvm crash though.. in the ime, at val himc: HIMC = HIMC(imm.getContext(hwnd))

@Sylvyrfysh
Copy link
Collaborator

So this appears to be a Windows specific issue, where the Imm Libraries cause a crash. I'll start playing around with e=that, just was finally able to get everything set up. @elect86 do you know if only one Imm context can be had per window, and possibly minecraft already has it?

Sylvyrfysh added a commit that referenced this issue Jun 16, 2019
@Sylvyrfysh
Copy link
Collaborator

Sylvyrfysh commented Jun 16, 2019

@elect86 I messes up the pulls on which branches but was planning to merge anyways. If you don't want the commit Cleanups/Javaifications, feel free to revert.

@niklasbuesing Using commit ccbbf10, set ImguiKt.MINECRAFT_BEHAVIORS = true before you create the GLFWWindow and this should resolve the problem. I was able to get the Demo Window up and showing. Let me know if this fixes it on your side as well.

The drawbacks to this method is that currently Imgui on minecraft will not receive IME events, so we'll have to see if we can reflect out the HWND MC has.

@niklasbuesing
Copy link
Author

Yep, works fine now! 👍

Thanks to everyone involved for their efforts. 😃

@elect86
Copy link
Collaborator

elect86 commented Jun 16, 2019

It's totally fine, let's merge it.. Nice workaround @Sylvyrfysh

Btw, I double checked ImmGetContext address is exaclty the same, only hwnd varies, but it looks somehow valid also on the small fabric sample.. I wonder what it is..

We might create an issue over there (https://github.com/FabricMC) to watch this issue in the long term and see if we find the culprit, I'm afraid this may have to do with something else under the hood.. (@niklasbuesing which repo would you suggest in their organization in this matter?)

@Sylvyrfysh
Copy link
Collaborator

Can someone post a zip of their simple example? i keep getting the glTexture2D crashes when trying to actually fix this

@AlexApps99
Copy link

AlexApps99 commented Sep 20, 2019

Example is not compiling for me on Java 8, glm seems to be compiled for Java 11...

/home/runner/work/examplemod/examplemod/src/main/java/io/github/examplemod/Imgui.java:3: error: cannot access Vec2
import glm_.vec2.Vec2;
                ^

> Task :compileJava FAILED
  bad class file: /home/runner/.gradle/caches/modules-2/files-2.1/com.github.kotlin-graphics.glm/glm/6048c31425ae6110258e4b42165f1e636f8b5603/be825795adf887a045ee19eb08db0eeff47b02fb/glm-6048c31425ae6110258e4b42165f1e636f8b5603.jar(glm_/vec2/Vec2.class)

    class file has wrong version 55.0, should be 52.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.

If there is any way I could get around this, I would appreciate it greatly.

Edit: removed import as it was unused, ImGUI now says its' classpath is for Java 11.

  bad class file: /home/runner/.gradle/caches/modules-2/files-2.1/com.github.kotlin-graphics.imgui/imgui-core/-SNAPSHOT/d872d341aa28c6ddf10430d6f22bd75911763ca2/imgui-core--SNAPSHOT.jar(imgui/ImGui.class)
    class file has wrong version 55.0, should be 52.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.

@AlexApps99
Copy link

It's probably worth asking, is this library compatible with Java 8, and compatible with Linux?
The README seems to advertise that but I'm not sure if it's still the case...

@AlexApps99
Copy link

Reading the build files seems to suggest this is a Java 11 library, how would I compile this for Java 8?

@Sylvyrfysh
Copy link
Collaborator

Change the value on the line here to 8. Don't know if that will compile though

@AlexApps99
Copy link

Will keep you posted if it doesn't work, thanks

@AlexApps99
Copy link

I don't think it'll work in my case as JitPack hosts this library compiled for Java 11 too.
The entire library would need to be recompiled for Java 8, dependencies included

@AlexApps99
Copy link

@elect86 Sorry for the incredibly late response, I've been preoccupied by other things and I never made any additional progress. I am not the one who opened the issue, so if @niklasbuesing is ok with it this can be closed.

@AlexApps99
Copy link

As a sidenote, since I am no longer working on this, I will remove myself from the organization.
Thanks for the wonderful libs you've given us!

@breadbyte
Copy link
Collaborator

For anyone who has stumbled upon this issue (and waiting for closure, presumably), i have taken an interest in this library and made a fabricmc template that works out of the box based on multiple issues and reports from this repository.

I have only tested this on linux, so i am unsure if issues still exist within windows.

https://github.com/breadbyte/fabric-example-imgui

@elect86
Copy link
Collaborator

elect86 commented May 6, 2020

@breadbyte if you want to add a link in the Readme and/or add a wiki page about that, dont hesitate

@melvyn2
Copy link

melvyn2 commented May 24, 2020

@breadbyte When I tried your fabric template, I still got class file has wrong version 55.0, should be 52.0. I'm probably doing something wrong, but I can't find out what.

@AlexApps99
Copy link

What that usually means is that you're compiling with the wrong version of Java (52 is Java 8, 55 is Java 11)

@melvyn2
Copy link

melvyn2 commented May 24, 2020

I'm trying to compile with Java 8, but the template is using ImGui compiled for Java 11. I tried to switch it to the jdk8 branch, but that cause a bunch of other errors. Before I go further in trying to fix them, I'm trying to see if the template creator ran into this.

@elect86
Copy link
Collaborator

elect86 commented May 25, 2020

I'm about to give a refresh to all the libs, I'll do also for the jdk8 branch

which kind of errors are you experiencing, @melvyn2?

@melvyn2
Copy link

melvyn2 commented May 25, 2020

I was dealing with the wrong problem, actually. When I ran the template with Java 12, I got a native crash. I realized that OpenJ9 might be causing the issue, so I switched to HotSpot.
That gave me a crash of java.lang.NullPointerException: A required function is missing: glfwGetMonitorWorkarea. After realizing this is platform specific code, I tried the template on linux, and everything worked out-of-box.
So, the real issue is that something breaks the template on macOS, but it works fine on linux.

@breadbyte
Copy link
Collaborator

Admittedly, I have not tested my template on both the Java 8 branch nor macOS as I don't have access to a macOS machine, and, for the record, I use AdoptOpenJDK 14 OpenJ9 on my machine.

I will do some more testing around.

@elect86
Copy link
Collaborator

elect86 commented May 26, 2020

I was dealing with the wrong problem, actually. When I ran the template with Java 12, I got a native crash. I realized that OpenJ9 might be causing the issue, so I switched to HotSpot.
That gave me a crash of java.lang.NullPointerException: A required function is missing: glfwGetMonitorWorkarea. After realizing this is platform specific code, I tried the template on linux, and everything worked out-of-box.
So, the real issue is that something breaks the template on macOS, but it works fine on linux.

According to Spasi, the error on macos

It means there's a version mismatch between the Java GLFW bindings and the corresponding natives.

@melvyn2 can you investigate in the glfw version you actually use on macos?

@melvyn2
Copy link

melvyn2 commented May 26, 2020

$ otool -L .gradle/caches/fabric-loom/natives/1.15.2/libglfw.dylib
.gradle/caches/fabric-loom/natives/1.15.2/libglfw.dylib:
	@rpath/libglfw.3.dylib (compatibility version 3.0.0, current version 3.3.0)
        ...

@elect86
Copy link
Collaborator

elect86 commented May 26, 2020

It doesn't look like it's loading LWJGL's glfw binary

@HvHBlackTeal
Copy link

HvHBlackTeal commented Jun 14, 2020

Hello, what's wrong with my build.gradle? I can't use jdk8 branch.

buildscript {
    repositories {
        maven { url = 'https://files.minecraftforge.net/maven' }
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
    }
}
apply plugin: 'net.minecraftforge.gradle'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'eclipse'

version = '1.0'
group = 'com.example.examplemod' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'examplemod'

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.

repositories {
    // ImGUI
    maven {
        url = "https://jitpack.io"
    }
    jcenter()
    mavenCentral()
}

dependencies {
    // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
    // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
    // The userdev artifact is a special name and will get all sorts of transformations applied to it.
    minecraft 'net.minecraftforge:forge:1.14.4-28.2.0'

    // ImGUI
    ["imgui-core", "imgui-gl", "imgui-glfw"].each {
        compile("com.github.kotlin-graphics.imgui:$it:jdk8-SNAPSHOT") {
            exclude group: "org.lwjgl"
        }
    }

}

// Example for how to get properties into the manifest for reading by the runtime..
jar {
    manifest {
        attributes([
                "Specification-Title": "examplemod",
                "Specification-Vendor": "examplemodsareus",
                "Specification-Version": "1", // We are version 1 of ourselves
                "Implementation-Title": project.name,
                "Implementation-Version": "${version}",
                "Implementation-Vendor" :"examplemodsareus",
                "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
        ])
    }
}

minecraft {
    // The mappings can be changed at any time, and must be in the following format.
    // snapshot_YYYYMMDD   Snapshot are built nightly.
    // stable_#            Stables are built at the discretion of the MCP team.
    // Use non-default mappings at your own risk. they may not always work.
    // Simply re-run your setup task after changing the mappings to update your workspace.
    mappings channel: 'snapshot', version: '20190719-1.14.3'

    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

    // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')

    // Default run configurations.
    // These can be tweaked, removed, or duplicated as needed.
    runs {
        client {
            workingDirectory project.file('run')

            // Recommended logging data for a userdev environment
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

            // Recommended logging level for the console
            property 'forge.logging.console.level', 'debug'

            mods {
                examplemod {
                    source sourceSets.main
                }
            }
        }

        server {
            workingDirectory project.file('run')

            // Recommended logging data for a userdev environment
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

            // Recommended logging level for the console
            property 'forge.logging.console.level', 'debug'

            mods {
                examplemod {
                    source sourceSets.main
                }
            }
        }

        data {
            workingDirectory project.file('run')

            // Recommended logging data for a userdev environment
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

            // Recommended logging level for the console
            property 'forge.logging.console.level', 'debug'

            args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/')

            mods {
                examplemod {
                    source sourceSets.main
                }
            }
        }
    }
}

image
Console Error Log:

Could not resolve all files for configuration ':compileClasspath'.
> Could not find com.github.kotlin-graphics.glm:glm:jdk8-SNAPSHOT.
  Searched in the following locations:
    - https://jitpack.io/com/github/kotlin-graphics/glm/glm/jdk8-SNAPSHOT/maven-metadata.xml
    - https://jitpack.io/com/github/kotlin-graphics/glm/glm/jdk8-SNAPSHOT/glm-jdk8-0ffefa69c4-1.pom
    - https://jitpack.io/com/github/kotlin-graphics/glm/glm/jdk8-SNAPSHOT/glm-jdk8-0ffefa69c4-1.jar
    - https://jcenter.bintray.com/com/github/kotlin-graphics/glm/glm/jdk8-SNAPSHOT/maven-metadata.xml
    - https://jcenter.bintray.com/com/github/kotlin-graphics/glm/glm/jdk8-SNAPSHOT/glm-jdk8-SNAPSHOT.pom
    - https://jcenter.bintray.com/com/github/kotlin-graphics/glm/glm/jdk8-SNAPSHOT/glm-jdk8-SNAPSHOT.jar
    - https://repo.maven.apache.org/maven2/com/github/kotlin-graphics/glm/glm/jdk8-SNAPSHOT/maven-metadata.xml
    - https://repo.maven.apache.org/maven2/com/github/kotlin-graphics/glm/glm/jdk8-SNAPSHOT/glm-jdk8-SNAPSHOT.pom
    - https://repo.maven.apache.org/maven2/com/github/kotlin-graphics/glm/glm/jdk8-SNAPSHOT/glm-jdk8-SNAPSHOT.jar
    - https://files.minecraftforge.net/maven/com/github/kotlin-graphics/glm/glm/jdk8-SNAPSHOT/maven-metadata.xml
    - https://files.minecraftforge.net/maven/com/github/kotlin-graphics/glm/glm/jdk8-SNAPSHOT/glm-jdk8-SNAPSHOT.pom
    - https://files.minecraftforge.net/maven/com/github/kotlin-graphics/glm/glm/jdk8-SNAPSHOT/glm-jdk8-SNAPSHOT.jar
    - file:/C:/Users/BlackTeal/.gradle/caches/forge_gradle/bundeled_repo/com/github/kotlin-graphics/glm/glm/jdk8-SNAPSHOT/maven-metadata.xml
    - file:/C:/Users/BlackTeal/.gradle/caches/forge_gradle/bundeled_repo/com/github/kotlin-graphics/glm/glm/jdk8-SNAPSHOT/glm-jdk8-SNAPSHOT.pom
    - file:/C:/Users/BlackTeal/.gradle/caches/forge_gradle/bundeled_repo/com/github/kotlin-graphics/glm/glm/jdk8-SNAPSHOT/glm-jdk8-SNAPSHOT.jar
    - https://libraries.minecraft.net/com/github/kotlin-graphics/glm/glm/jdk8-SNAPSHOT/maven-metadata.xml
    - https://libraries.minecraft.net/com/github/kotlin-graphics/glm/glm/jdk8-SNAPSHOT/glm-jdk8-SNAPSHOT.jar
    - https://repo.maven.apache.org/maven2/com/github/kotlin-graphics/glm/glm/jdk8-SNAPSHOT/maven-metadata.xml
    - https://repo.maven.apache.org/maven2/com/github/kotlin-graphics/glm/glm/jdk8-SNAPSHOT/glm-jdk8-SNAPSHOT.pom
    - https://repo.maven.apache.org/maven2/com/github/kotlin-graphics/glm/glm/jdk8-SNAPSHOT/glm-jdk8-SNAPSHOT.jar
  Required by:
      project : > com.github.kotlin-graphics.imgui:imgui-core:jdk8-SNAPSHOT:76fb7ed8bf-1
      project : > com.github.kotlin-graphics.imgui:imgui-gl:jdk8-SNAPSHOT:76fb7ed8bf-1
      project : > com.github.kotlin-graphics.imgui:imgui-glfw:jdk8-SNAPSHOT:76fb7ed8bf-1
      project : > com.github.kotlin-graphics.imgui:imgui-gl:jdk8-SNAPSHOT:76fb7ed8bf-1 > com.github.kotlin-graphics.uno-sdk:uno-core:jdk8-SNAPSHOT:b51033d51d-1
      project : > com.github.kotlin-graphics.imgui:imgui-gl:jdk8-SNAPSHOT:76fb7ed8bf-1 > com.github.kotlin-graphics.uno-sdk:uno-gl:jdk8-SNAPSHOT:b51033d51d-1
      project : > com.github.kotlin-graphics.imgui:imgui-core:jdk8-SNAPSHOT:76fb7ed8bf-1 > com.github.kotlin-graphics:uno-sdk:jdk8-SNAPSHOT:b51033d51d-1 > com.github.kotlin-graphics.uno-sdk:uno-awt:jdk8-SNAPSHOT:b51033d51d-1

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

@elect86
Copy link
Collaborator

elect86 commented Jun 15, 2020

@HvHBlackTeal glm now doesn't have anymore 2 module, that means this:
com.github.kotlin-graphics.glm:glm:jdk8-SNAPSHOT

shall be instead as follow
com.github.kotlin-graphics:glm:jdk8-SNAPSHOT

@HvHBlackTeal
Copy link

HvHBlackTeal commented Jun 16, 2020

But I'm not using

com.github.kotlin-graphics.glm:glm:jdk8-SNAPSHOT

on my code, I'm using

["gl", "glfw", "core"].each {
    implementation("com.github.kotlin-graphics.imgui:imgui-$it:jdk8-SNAPSHOT") {
        com.github.kotlin-graphics.glm:glm:jdk8-SNAPSHOT
    }
}

to import ImGui, using

implementation("com.github.kotlin-graphics:glm:jdk8-SNAPSHOT")
["gl", "glfw", "core"].each {
    implementation("com.github.kotlin-graphics.imgui:imgui-$it:jdk8-SNAPSHOT") {
        exclude group: "org.lwjgl"
    }
}

also doesn't work and I get the same error, if I use default ImGui version but jdk8 glm, it says that ImGui classes are bad, they're 55.0 and should be 52.0, imgui-gl is causing this problem, if I implement this as jdk8, it tries do find glm/glm insteand of glm, doesn't find and the compilation fails, if I implement as java 11 it doesn't work because ImGui classes are bad, I'm trying to implement ImGui in a forge mod.

@elect86
Copy link
Collaborator

elect86 commented Jun 16, 2020

I'm in the process of refreshing the jdk8 branches along the organizations, however I'm experiencing some troubles on uno-sdk and jpms

I'll suppress the error to give you quickly the possibility to test

@elect86
Copy link
Collaborator

elect86 commented Jun 19, 2020

@HvHBlackTeal 6595496 70aabce

@gurachan
Copy link

any news?

@zeroeightysix
Copy link
Collaborator

any news?

Assuming you are:

  • Running minecraft 1.13 or up (LWJGL 3)
  • Using the jdk8 branch (linked by elect above)

imgui works quite well in minecraft aside from the occasional occurence of #114 - of which I still haven't found the cause.

@gurachan
Copy link

gurachan commented Sep 2, 2020

@breadbyte this https://github.com/breadbyte/fabric-example-imgui is almost perfect ... this what happens if you leave the input open then close the screen. you cant type anymore :'(

sad

@gurachan
Copy link

gurachan commented Sep 2, 2020

another example that I can't type after I reopen the screen after typing

SADD2

@breadbyte
Copy link
Collaborator

The issues @Dj-jom2x are experiencing seem to be issues from my template specifically.
I've fixed it in my template.

breadbyte/fabric-example-imgui@0b11740
The issue seems to be that the esc key was also propagating into imgui, causing imgui to also handle the esc key.
I've decided to drop the esc key from being processed into imgui at all, since Minecraft's esc key handler would be more useful in this case. This is just a quick fix, so if there's a better way to handle this, please do tell me.

@gurachan
Copy link

gurachan commented Sep 4, 2020

The issues @Dj-jom2x are experiencing seem to be issues from my template specifically.
I've fixed it in my template.

breadbyte/fabric-example-imgui@0b11740
The issue seems to be that the esc key was also propagating into imgui, causing imgui to also handle the esc key.
I've decided to drop the esc key from being processed into imgui at all, since Minecraft's esc key handler would be more useful in this case. This is just a quick fix, so if there's a better way to handle this, please do tell me.

it seems working just fine xD thanks. what I did for the temp fix.

	@Override
	public void onClose() {
		ctx.destroy(); // you need to create new context again because u destroy it
		super.onClose();
	}

but every time you start the gui.. the currently selected tabs are being reset all opened collapsingHeader is being reset..

... but your solution works great xD because it keeps the current selected tabs and current opened collapsingHeader..

@elect86
Copy link
Collaborator

elect86 commented Sep 4, 2020

We may add an option to avoid propagating the esc key, whay to you think?

@gurachan
Copy link

gurachan commented Sep 4, 2020

@breadbyte also stop the handle of the enter key.. it does the same bug.. can't type because it loses its focus so hard. I ignored keycode 257 now its fine.

@breadbyte
Copy link
Collaborator

@Dj-jom2x I'm not sure if that would be a good idea, as the enter key provides actual useful functionality on imgui.

I've decided to fix it on my template using an input buffer instead, when minecraft closes the screen, the input buffer sends a keyrelease for every input on the buffer.

The reason why this is required is that when minecraft closes the screen, imgui cannot receive the keyreleased event, therefore on imgui's side it's as if it was never released at all.


Adding an option to stop the esc key from being handled would be a good candidate for a default minecraft behavior, i think.
Although minecraft has a shouldCloseOnEsc option, it's set to true by default, making imgui's esc key handler impossible to use due to, well, the screen has closed before anything useful could come out of it, so i don't know if it should be set as a toggle on imgui because the option could be toggled independently outside of imgui.

@gurachan
Copy link

gurachan commented Sep 6, 2020

@breadbyte very thanks.

I noticed when using inputTextEx and using

private static byte[] msg = new byte[256];

so for instance you make a

ArrayList<String> items = new ArrayList<String>();

you trim the msg by

   String _data = new String(msg).trim();

then add it to item

 items.add(_data);

then clear the msg by

msg = new byte[256];

there are 1/10 chances that you will get ??? next to the text you just say. am i doing it wrong?

I tried the string version too .. Using inputText that uses String as buffer is not helpful .. so if you create a string that has value "hello" then use that as buffer ... you can only type 5 letters or the total of letters.

also if you clear the msg buffer while u still typing so your focus is still on the input box.. the text is not gone... unless u click somewhere else. it will be nice if they act as a normal text input where they respect what is the current value regardless of focus

@elect86
Copy link
Collaborator

elect86 commented Apr 13, 2021

Hey,

what's the status on this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants