lukflug / PanelStudio

An extensible and customizable GUI API/library to create ClickGUIs, HUDEditors and TabGUIs designed for use in Minecraft utility mods.
https://lukflug.github.io/panelstudio.html
MIT License
309 stars 23 forks source link

gui.enterGUI() gives an error. #16

Closed Whop42 closed 3 years ago

Whop42 commented 3 years ago

It also doesn't open the ClickGUI. The source is here. This is the error:

[15:51:30] [main/INFO] (Minecraft) [STDERR]: java.lang.reflect.InvocationTargetException
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at net.dent.client.event.Event.lambda$call$0(Event.java:41)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at java.base/java.util.concurrent.CopyOnWriteArrayList.forEach(CopyOnWriteArrayList.java:807)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at net.dent.client.event.Event.call(Event.java:39)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at net.minecraft.client.Keyboard.handler$zhh000$onOnKey(Keyboard.java:517)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at net.minecraft.client.Keyboard.onKey(Keyboard.java)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at net.minecraft.client.Keyboard.method_22678(Keyboard.java:385)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at net.minecraft.util.thread.ThreadExecutor.execute(ThreadExecutor.java:86)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at net.minecraft.client.Keyboard.method_22676(Keyboard.java:385)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at org.lwjgl.glfw.GLFWKeyCallbackI.callback(GLFWKeyCallbackI.java:37)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at org.lwjgl.system.JNI.invokeV(Native Method)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3101)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:89)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at net.minecraft.client.util.Window.swapBuffers(Window.java:339)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at net.minecraft.client.MinecraftClient.render(MinecraftClient.java:1026)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at net.minecraft.client.MinecraftClient.run(MinecraftClient.java:624)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at net.minecraft.client.main.Main.main(Main.java:187)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:226)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:139)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:27)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at net.fabricmc.devlaunchinjector.Main.main(Main.java:86)
[15:51:30] [main/INFO] (Minecraft) [STDERR]: Caused by: java.lang.NullPointerException
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at net.dent.client.module.modules.render.GUI.onEnable(GUI.java:20)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at net.dent.client.module.Module.toggle(Module.java:91)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    at net.dent.client.module.ModuleManager.onKey(ModuleManager.java:61)
[15:51:30] [main/INFO] (Minecraft) [STDERR]:    ... 28 more

The game does not crash.

How do I fix this?

ChompChompDead commented 3 years ago

What i notice is that when u open youf clickgui, you instantly toggle it after making it disable. For the crash, im still trying to figure out what is wrong with it

ChompChompDead commented 3 years ago

I think i know the reason why it is crashing. First, you need a colormodel mode setting that tells whether or not to use HSB or RGB. The fields in toggleable need to be filled with that setting. The toggle() method should be filled with the ColorModel setting incrementing. (think about it as a mode setting incrementing from one mode to another.) The isOn method should be filled with whether or not to use RGB or HSB, with the colorModel setting too. Hopefully this helped you, if not then idk what else to think of

lukflug commented 3 years ago

Are you sure the PanelStudio classes are even loaded? Are you running this in a dev environment or in the launcher?

Whop42 commented 3 years ago

Are you sure the PanelStudio classes are even loaded? Are you running this in a dev environment or in the launcher?

I'm running it from IntelliJ, and it builds so I think the classes are loading

you need a colormodel mode setting that tells whether or not to use HSB or RGB

I'm doing that right now, but I'm not sure it will work

Whop42 commented 3 years ago

Nope, I'm still getting the same error.

ChompChompDead commented 3 years ago

You need to make your seettings and module system implement panelstudios. For your settings, there are 5 that panelstudio has. EnumSetting (mode) ColorSetting,KeybindSetting, Toggleable (boolean), and NumberSetting make your settings implement that and also include the override methods that the interface requires. Next make your module file (not a modulemanager) implement Toggleable too and also include the override methods that it needs. Hoped this help you

lukflug commented 3 years ago

Ok, it's almost certainly caused by DentClient.instance.gui never being initialized.

Whop42 commented 3 years ago

Is this how it should be initialized?

public enum DentClient {

    instance;

    public static String name = "Dent Client";
    public static String author = "Whop42";
    public static String version = "0.2.42";
    public static String game = "1.16.5";
    private boolean ghostMode = false;

    public EventManager eventManager;
    public ModuleManager moduleManager;
    public SettingManager settingManager;
    public CommandManager commandManager;
    public ConfigManager configManager;
    public Guey gui;

    public void run() {
        eventManager = new EventManager();
        moduleManager = new ModuleManager();
        settingManager = new SettingManager();
        commandManager = new CommandManager();
        configManager = new ConfigManager();
        gui = new Guey();
        moduleManager.loadMods();
        commandManager.loadCommands();
        configManager.loadConfig();

    }

    public void stop() {
        configManager.saveConfig();
    }

    public static String getVersion() {
        return version;
    }

    public static String getName() {
        return name;
    }

    public boolean isGhost() {
        return ghostMode;
    }

    public void setGhostMode(boolean value) {
        ghostMode = value;
    }

}

Because if it is, it returns this slightly different error:

[12:58:37] [main/INFO] (Minecraft) [STDERR]: java.lang.reflect.InvocationTargetException
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at jdk.internal.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at net.dent.client.event.Event.lambda$call$0(Event.java:41)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at java.base/java.util.concurrent.CopyOnWriteArrayList.forEach(CopyOnWriteArrayList.java:807)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at net.dent.client.event.Event.call(Event.java:39)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at net.minecraft.client.Keyboard.handler$zhh000$onOnKey(Keyboard.java:517)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at net.minecraft.client.Keyboard.onKey(Keyboard.java)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at net.minecraft.client.Keyboard.method_22678(Keyboard.java:385)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at net.minecraft.util.thread.ThreadExecutor.execute(ThreadExecutor.java:86)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at net.minecraft.client.Keyboard.method_22676(Keyboard.java:385)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at org.lwjgl.glfw.GLFWKeyCallbackI.callback(GLFWKeyCallbackI.java:37)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at org.lwjgl.system.JNI.invokeV(Native Method)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3101)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:89)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at net.minecraft.client.util.Window.swapBuffers(Window.java:339)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at net.minecraft.client.MinecraftClient.render(MinecraftClient.java:1026)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at net.minecraft.client.MinecraftClient.run(MinecraftClient.java:624)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at net.minecraft.client.main.Main.main(Main.java:187)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:226)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:139)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:27)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at net.fabricmc.devlaunchinjector.Main.main(Main.java:86)
[12:58:37] [main/INFO] (Minecraft) [STDERR]: Caused by: java.lang.NullPointerException
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at com.lukflug.panelstudio.mc16.MinecraftGUI.enterGUI(MinecraftGUI.java:46)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at net.dent.client.module.modules.render.GUI.onEnable(GUI.java:20)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at net.dent.client.module.Module.toggle(Module.java:91)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    at net.dent.client.module.ModuleManager.onKey(ModuleManager.java:61)
[12:58:37] [main/INFO] (Minecraft) [STDERR]:    ... 27 more
ChompChompDead commented 3 years ago

You need to implement panelstudio setting interfaces within your settings, like what i said in the post above. Also implement the Toggleable interface in your module class.

ChompChompDead commented 3 years ago

Also yes that is how you instantiate the clickgui class

ChompChompDead commented 3 years ago

You may want to create seperate classes inside the setting instead of seperate constructors so you can implement them

lukflug commented 3 years ago

This is a build.gradle issue:

compile "com.lukflug:panelstudio:0.1.8"
modCompile "com.lukflug:panelstudio-mc16:0.1.8"

instead of

compile "com.lukflug:panelstudio:0.1.8"
compile "com.lukflug:panelstudio-mc16:0.1.8"
Whop42 commented 3 years ago

This is a build.gradle issue:

Still get an error for that

You need to implement panelstudio setting interfaces within your settings, like what i said in the post above. Also implement the Toggleable interface in your module class.

The Module class implements Toggleable, and I have converters/shells/whatever for the settings (I might just rewrite my setting base if i need to...)

ChompChompDead commented 3 years ago

yeah maybe u need to rewrite your settings to use panelstudio

Whop42 commented 3 years ago

I don't think the settingbase being different than panelstudio's would cause the gui to not even open

ChompChompDead commented 3 years ago

I saw an error in the events system, maybe u wanna check it out and see how it works?

Whop42 commented 3 years ago

It's just the keyboard event being called

ChompChompDead commented 3 years ago

Can u push the lastest changes to github so i can see or is it already updated

lukflug commented 3 years ago

The settings don't have anything to do with the runtime issue.

This is a build.gradle issue:

Still get an error for that

You need to implement panelstudio setting interfaces within your settings, like what i said in the post above. Also implement the Toggleable interface in your module class.

The Module class implements Toggleable, and I have converters/shells/whatever for the settings (I might just rewrite my setting base if i need to...)

What do you mean with "Still get an error for that"? Is it the same error or a different one, have you tried a clean build?

Whop42 commented 3 years ago

Its the same one

lukflug commented 3 years ago

Could you push your newest changes on GitHub and I will make a pull request trying to fix this for you soon?

Whop42 commented 3 years ago

The changes were pushed when ChompChompDead asked for it, I forgot to say something sry.

lukflug commented 3 years ago

Use PanelStudio 0.1.8 and PanelStudio-MC16 0.1.9!